Skip to content

Conversation

@ben-manes
Copy link

@ben-manes ben-manes commented Mar 5, 2025

Use a stronger hashing function for cache keys to assist in a uniform distribution within the hash table. This mitigates a performance regression in Ehcache due to clustering effects resulting in an O(n) eviction.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19218

@Sanne
Copy link
Member

Sanne commented Oct 6, 2025

Hi @ben-manes , thank you so much for caring!

I'm wondering though - while Ehcache is popular in many cases we recommend using caches which are based on your Caffeine library (either directly, such as in Quarkus, or through Infinispan to add distributed capabilities, like in WildFly).
Would you say it's responsibility of the ORM to generate a stronger hash, or should we have such a function applied only in selected integrations?

I'd have no problem in merging this if you believe this is the right level.

@ben-manes
Copy link
Author

I would definitely consider this the responsibility of the cache vendor, not a consumer like Hibernate. That is why Java's hash tables use a spreader function where helpful and Ehcache's oversight meant it did not work as they intended. There wasn't a choice since they decided to ignore the issue for over a decade, but thankfully it is fixed in the latest release. I think this can be closed as anyone upgrading to a later Hibernate will surely upgrade Ehcache and be protected. Thanks!

@ben-manes ben-manes closed this Oct 6, 2025
@gavinking
Copy link
Member

@ben-manes Thanks so much for following up. 🙏

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.

3 participants