Note that cache impls are monotonically increasing counters in Javadoc - #6516
Open
Amemeda wants to merge 3 commits into
Open
Note that cache impls are monotonically increasing counters in Javadoc#6516Amemeda wants to merge 3 commits into
Amemeda wants to merge 3 commits into
Conversation
Amemeda
commented
Aug 26, 2026
Comment on lines
45
to
49
| @Override | ||
| public void registerMetrics(MeterRegistry registry) { | ||
| ToDoubleFunction<BlockCache> getHitCount = cache -> cache.getStats().hitCount(); | ||
| ToDoubleFunction<BlockCache> getRequestCount = cache -> cache.getStats().requestCount(); | ||
|
|
Contributor
Author
There was a problem hiding this comment.
This was the only area I could find "cache impls" using the counters, if there are more, I may need to pointed in the right direction
DomGarguilo
requested changes
Aug 27, 2026
DomGarguilo
left a comment
Member
There was a problem hiding this comment.
I think BlockCacheMetrics is the wrong spot for this comment since its internal code that nobody implements. The intent should be to notify plugin authors. I think the BlockCache.Stats interface is the correct spot for things.
This BlockCache implementation is a monotonically increasing counter, the counter should not reset or
decrease the counts as the metrics rely on these values being monotonically increasing.
I also think this could be improved in a few ways
- the counts are monotonic not the cache. Something like "All counts returned by this interface must be monotonically increasing" seems more correct to me
- since the goal is to outline the contract we should say "must never" instead of "should not" so it reads as a requirement instead of a suggestion
- I think the why could be improved. "shouldn't reset because the metrics rely on it not resetting" is kinda what its saying now which is circular reasoning. Something that explains that the values are read periodically and what matters is how much things go up between those readings so an implementation must never reset or decrease them.
dlmarion
approved these changes
Aug 27, 2026
DomGarguilo
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update SPI javadoc to note that cache impls are monotonically increasing counters.
Added to javadoc in
BlockCache.Stats.javainterface.This pr closes #4530