Fix cache metrics - #83
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts in-memory cache implementations to avoid treating re-inserting an already-cached key as an eviction, and adds a regression test to validate the corrected metrics behavior across cache policies.
Changes:
- Prevent
putfrom evicting/replacing an existing entry when the key is already present (Lru, S3Fifo, TinyLfu). - Add a test ensuring re-putting the same key does not increment eviction metrics and does not inflate the in-cache count.
Suppressed comments (2)
quickwit/quickwit-storage/src/cache/base_cache.rs:339
contains_keyshort-circuits re-puts without updating the cache policy's internal access state. If duplicateputs happen due to concurrent miss races, the entry won't have its recency refreshed, which can lead to premature eviction. Usinggethere aligns better with the "immutable payload" pattern used inDiskSizedCache::put(which refreshes recency on already-cached keys).
if self.cache.contains_key(&key) {
return;
}
quickwit/quickwit-storage/src/cache/base_cache.rs:467
- As with the other policies, short-circuiting on
contains_keymakes re-puts a pure no-op and does not refresh TinyLFU's internal access/frequency state. If re-puts happen due to concurrent miss races, this can undercount how "hot" the entry is and lead to earlier eviction than intended; usinggetwould refresh policy state without changing your metrics counters.
if self.cache.contains_key(&key) {
return;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Darkheir
approved these changes
Aug 28, 2026
There was a problem hiding this comment.
🟡 Changes recommended
File-descriptor eviction accounting still incorrectly counts duplicate inserts and unsuccessful removals.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
rdettai-sk
force-pushed
the
fix-cache-metrics
branch
from
September 2, 2026 07:36
bac5030 to
dcfc775
Compare
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.
Description
Go through the cache metrics to make sure they are correct.
I didn't find any hit rate miss-calculation yet.
How was this PR tested?
Describe how you tested this PR.