Skip to content
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

Improve SimpleKey hashing function #34483

Closed
bclozel opened this issue Feb 25, 2025 · 0 comments
Closed

Improve SimpleKey hashing function #34483

bclozel opened this issue Feb 25, 2025 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Feb 25, 2025

SimpleKey is used in Spring Framework's caching support and its hashCode value can be used to efficiently store this key in data structures. As discussed with @ben-manes, the current hashcode strategy works, but the resulting values don't spread well enough when input keys are sequential (which is often the case). This can have negative performance impacts, depending on the data structures used by the cache implementation.

We should improve the hashCode function with a mixer function to better spread the hash values. While this is not a bug in Spring Framework this should improve performance for some cache implementations in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant