Skip to content

Expose cache stats#79

Merged
dentiny merged 4 commits into
mainfrom
hjiang/expose-cache-stats
Apr 21, 2026
Merged

Expose cache stats#79
dentiny merged 4 commits into
mainfrom
hjiang/expose-cache-stats

Conversation

@dentiny

@dentiny dentiny commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Closes: #59

This PR exposes cache stats: overall memory consumption, cache hit and total access count.

@dentiny dentiny changed the title [WIP] Expose cache stats Expose cache stats Apr 20, 2026
}

void ConditionCacheStore::RecordAccess(bool hit) {
total_accesses.fetch_add(1, std::memory_order_relaxed);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for performance?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes. Opus generated the code and I think it's fine. For cache access stats we don't need to be 100% precise, but I could change it


auto store = ConditionCacheStore::GetOrCreate(context);
auto entry = store->Lookup(context, key);
store->RecordAccess(entry != nullptr);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

note: this should be refactored after we introduce #78, otherwise the lookup hit doesnt mean query can actually use them to reduce the IO and materalize overhead

Comment thread src/query_condition_cache_state.cpp Outdated
@dentiny dentiny requested a review from peterxcli April 21, 2026 09:11

@peterxcli peterxcli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@dentiny dentiny merged commit 86ada82 into main Apr 21, 2026
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.

Add metrics for overall cache stats

2 participants