Skip to content

Conversation

@snazy
Copy link
Member

@snazy snazy commented Oct 30, 2025

The read of Eviction properties is "just" a volatile read since Caffeine 3.2.3 and trigger cleanups asynchronously. Before 3.2.3, cleanups happened synchronously. This change breaks the initially present assertions of this test, but not the functionality of the production code. See ben-manes/caffeine#1897

}

// The read of `Eviction` properties is "just" a volatile read since Caffeine 3.2.3
// and trigger cleanups asynchronously. Before 3.2.3, cleanups happened synchronously.
Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with this upgrade, but I believe it will actually change "prod" code behaviour. Specifically, I expect the test I reported here to result in different memory allocation behaviour.

Do you think it's worth re-running that test?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it doesn't hurt re-running that test.

@snazy
Copy link
Member Author

snazy commented Nov 3, 2025

Um - so @RetryingTest doesn't like softly

…adopt tests

The read of `Eviction` properties is "just" a volatile read since Caffeine 3.2.3 and trigger cleanups asynchronously. Before 3.2.3, cleanups happened synchronously.  This change breaks the initially present assertions of this test, but not the functionality of the production code.
There is sadly no fix possible with Caffeine since 3.2.3. See [this reply](ben-manes/caffeine#1897 (comment)).

The workaround I came up with is to change the logic a bit:

* If the cache-weight is less than the capacity: just put the entry to the cache, no "special handling".
* Otherwise do the following while holding an exclusive lock:
  * Explicitly trigger cache cleanup
  * If the cache-weight is less than the admitted capacity (overshooting), put the entry into the cache.
  * Else, reject and update meters accordingly.

We have to allow the "overshooting" to happen to enable (and trigger) the cache cleanup. Otherwise, cleanup would never happen ...
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