⚡️ Speed up method Filter.geoWithinRegionByIndex by 11%#103
Open
codeflash-ai[bot] wants to merge 1 commit intofix/add-mockito-test-dependencyfrom
Open
Conversation
This change reduces runtime by 11% (11.6 μs → 10.4 μs) by calling Value.get(region) once and reusing that Value for both begin and end instead of creating two Value objects. Reusing the single Value eliminates one method call and one object allocation per Filter construction, cutting per-invocation CPU and allocation overhead on the hot path. Trade-off: begin and end now share the same Value instance (i.e., object identity is aliased), which is appropriate for the effectively immutable Value type and produced no measurable test regressions while slightly lowering memory churn.
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.
📄 11% (0.11x) speedup for
Filter.geoWithinRegionByIndexinclient/src/com/aerospike/client/query/Filter.java⏱️ Runtime :
11.6 microseconds→10.4 microseconds(best of169runs)📝 Explanation and details
This change reduces runtime by 11% (11.6 μs → 10.4 μs) by calling Value.get(region) once and reusing that Value for both begin and end instead of creating two Value objects. Reusing the single Value eliminates one method call and one object allocation per Filter construction, cutting per-invocation CPU and allocation overhead on the hot path. Trade-off: begin and end now share the same Value instance (i.e., object identity is aliased), which is appropriate for the effectively immutable Value type and produced no measurable test regressions while slightly lowering memory churn.
✅ Correctness verification report:
🌀 Click to see Generated Regression Tests
To edit these changes
git checkout codeflash/optimize-Filter.geoWithinRegionByIndex-mmbtvlcnand push.