-
Notifications
You must be signed in to change notification settings - Fork 12
Smaller adjustments to buy us capacity #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements several performance optimizations aimed at reducing CPU cycles, instructions, branches, and cache misses without changing the runtime behavior. The changes focus on optimizing hot code paths in data processing and hash computation.
Key changes:
- Replace reflection-based object creation with direct instantiation using switch expressions for common data types
- Optimize hash computation algorithms to reduce operations and improve cache efficiency
- Remove unnecessary hash computation calls during object initialization
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| DataRecordFactory.java | Replaces reflection with switch-based direct instantiation for common data record types |
| XltCharBuffer.java | Refactors hash computation to reduce operations and improve performance |
| AbstractData.java | Removes premature hash computation during object initialization |
| StringHasher.java | Adds optimized hash method for XltCharBuffer using native String operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| for (; i < l2; i++) | ||
| { | ||
| h = 31 * h + src[i]; | ||
| h = (src[i] - h) + (h << 5); |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash computation formula (src[i] - h) + (h << 5) differs significantly from the standard multiplication-based approach used in the main loop. This inconsistency makes the algorithm harder to understand and may produce different hash distribution characteristics. Consider using a consistent approach like h = 31 * h + src[i] or document why this specific formula was chosen.
| h = (src[i] - h) + (h << 5); | |
| h = 31 * h + src[i]; |
| String _s = s.toString(); | ||
| final int pos = _s.indexOf(limitingChar); | ||
| if (pos > 0) | ||
| { | ||
| return _s.substring(0, pos).hashCode(); | ||
| } | ||
| else | ||
| { | ||
| return _s.hashCode(); | ||
| } |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition pos > 0 will skip hashing when the limiting character is at position 0, returning the full string's hash instead of an empty string's hash. This should be pos >= 0 to handle the case where the limiting character is the first character correctly.
These changes won't change the runtime but the resource need, aka freeing things up. Less branches, less instructions, less cycles, less cache misses.
Old Performance Data
New Performance Data