perf: unroll first probe in ClassNameFilter.contains()#67
Open
perf: unroll first probe in ClassNameFilter.contains()#67
Conversation
Unroll the first hash probe out of the loop since it is the most common path (hit on first try). Also inline the rehash function in the collision loop to avoid method call overhead. Benchmark results (ClassNameFilterBenchmark, spring-web.jar dataset): Single-threaded: cacheSize=4096: 6.458 -> 6.166 us/op (-4.5%) cacheSize=65536: 6.654 -> 6.304 us/op (-5.3%) Multi-threaded (10 threads): cacheSize=4096: 12.006 -> 8.726 us/op (-27.3%) cacheSize=16384: 11.112 -> 9.327 us/op (-16.1%) cacheSize=65536: 10.865 -> 8.604 us/op (-20.8%) cacheSize=1048576:11.140 -> 8.695 us/op (-22.0%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
What Does This Do
Unroll the first hash probe in
ClassNameFilter.contains()out of the loop, since it is the most common path (hit on first try). Also inline the rehash function in the collision loop to avoid method call overhead.Motivation
Benchmarking
ClassNameFilterBenchmarkagainst spring-web.jar showed significant multi-threaded improvement:Single-threaded:
Multi-threaded (10 threads):
The unrolled first probe avoids loop setup overhead and likely reduces contention in multi-threaded scenarios.
Additional Notes
contains()is changed;add()is unchangedContributor Checklist
Jira ticket: N/A — performance optimization, no ticket
🤖 Generated with Claude Code