Optimize numeric conversion: 34% speedup for bitwise operations#282
Merged
Optimize numeric conversion: 34% speedup for bitwise operations#282
Conversation
Performance improvements: - Replace INTEGER_PATTERN regex with simple mightBeInteger() char check in RuntimeScalar.getLong() and getInt() - Add fast-path in ScalarUtils.looksLikeNumber() for INTEGER/DOUBLE types - Split looksLikeNumber into inline fast-path + slow-path method Benchmark (life_bitpacked.pl 200x200 grid, 10000 generations): - Before: ~506 gen/s - After: ~680 gen/s (+34%) The regex pattern matching was creating new Matcher objects on every numeric conversion. Replacing with a simple first-character check avoids this overhead while still preventing exception costs for obviously non-numeric strings. Also adds .cognition/skills/profile-perlonjava/ with JFR profiling workflow documentation. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Static apply methods already check compilerSupplier before calling instance apply. This adds applyCompiled() that skips the second check for compiled code. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
…r check" This reverts commit 4a90984.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Performance improvements for numeric conversions in the runtime:
INTEGER_PATTERNregex with simplemightBeInteger()char check inRuntimeScalar.getLong()andgetInt()ScalarUtils.looksLikeNumber()for INTEGER/DOUBLE typeslooksLikeNumberinto inline fast-path + slow-path method for better JIT inliningBenchmark
Using
life_bitpacked.pl(200x200 grid, 10000 generations):Root Cause
The regex pattern matching was creating new
Matcherobjects on every numeric conversion:Test Plan
int("123"),int("-45"),int("1.5"),int("hello")Additional Changes
Adds
.cognition/skills/profile-perlonjava/with JFR profiling workflow documentation for future optimization work.Generated with Devin