Skip to content

Conversation

@chrisdennis
Copy link
Member

Prevent hash 'clumping' where unevenness in table slot usage can be exacerbated by the fact that we sample uniformly through the table, but not through the table usage when creating a traverser for selecting our eviction sample. This leads to slots in low density areas having a higher chance of being evicted, therefore leading to increased clumping. To prevent this we start traversers at the start of the table and then recycle them for subsequent evictions as they are exhausted. This ensures every slot has an equal chance of being selected for eviction.

Copy link
Member

@jhouserizer jhouserizer left a comment

Choose a reason for hiding this comment

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

Looks all sane to me!

for (Node<K, V> p; (p = t.advance()) != null;) {
boolean exhausted = false;
try {
for (Node<K, V> p; (p = t.advance()) != null; ) {
Copy link

Choose a reason for hiding this comment

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

Does this always skip/advance past the table 0 if 't' happens to be the one that was just instantiated above?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, traverser start "before" the first entry, so successive calls to advance every entry in sequence.

@chrisdennis chrisdennis reopened this Aug 14, 2025
@jhouserizer jhouserizer merged commit 962f2d0 into ehcache:master Aug 14, 2025
7 checks passed
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.

4 participants