Skip to content

Fix cache metrics - #83

Merged
rdettai-sk merged 4 commits into
sekoiafrom
fix-cache-metrics
Sep 2, 2026
Merged

Fix cache metrics#83
rdettai-sk merged 4 commits into
sekoiafrom
fix-cache-metrics

Conversation

@rdettai-sk

@rdettai-sk rdettai-sk commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI lite review requested due to automatic review settings August 28, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 put from 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_key short-circuits re-puts without updating the cache policy's internal access state. If duplicate puts happen due to concurrent miss races, the entry won't have its recency refreshed, which can lead to premature eviction. Using get here aligns better with the "immutable payload" pattern used in DiskSizedCache::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_key makes 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; using get would 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.

Comment thread quickwit/quickwit-storage/src/cache/base_cache.rs Outdated
@rdettai-sk
rdettai-sk requested a review from Darkheir August 28, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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

Comment thread quickwit/quickwit-storage/src/file_descriptor_cache.rs
@rdettai-sk
rdettai-sk merged commit 341d86b into sekoia Sep 2, 2026
3 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.

3 participants