Skip to content

intern EquivalenceKeys for primitive types and class types of java.* #540

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

Merged

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Jul 2, 2025

Primitive types and java.* class types are very commonly used and there is a limited number of them. Therefore, we can intern them safely (growth of the interning cache is naturally bounded) and improve allocation rate significantly.

Further, this commit removes all calls to Objects.hash(), because each call allocates an array. It is especially useless when called with just one element.

Co-authored-by: Guillaume Smet guillaume.smet@gmail.com

@Ladicek Ladicek added this to the 3.3.2 milestone Jul 2, 2025
@Ladicek Ladicek changed the title intern EquivalenceKeys for primitive types and class types of java.* intern EquivalenceKeys for primitive types and class types of java.* Jul 2, 2025
Primitive types and `java.*` class types are very commonly used and there
is a limited number of them. Therefore, we can intern them safely (growth
of the interning cache is naturally bounded) and improve allocation rate
significantly.

Further, this commit removes all calls to `Objects.hash()`, because each call
allocates an array. It is especially useless when called with just one element.

Co-authored-by: Guillaume Smet <guillaume.smet@gmail.com>
@Ladicek Ladicek force-pushed the improve-equivalence-key-allocation-rate branch from b200cac to 5e41373 Compare July 3, 2025 14:14
Copy link
Contributor

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a very good first step.

@Ladicek Ladicek merged commit 35114fe into smallrye:main Jul 3, 2025
35 checks passed
@Ladicek Ladicek deleted the improve-equivalence-key-allocation-rate branch July 3, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants