perf: CLOCK eviction cache for file contents (#208)#259
Merged
justrach merged 1 commit intorelease/v0.2.57from Apr 13, 2026
Merged
perf: CLOCK eviction cache for file contents (#208)#259justrach merged 1 commit intorelease/v0.2.57from
justrach merged 1 commit intorelease/v0.2.57from
Conversation
) Explorer.contents was an unbounded StringHashMap holding all file contents in memory (1.7GB peak RSS on 5K-file repos). Replace with a fixed-size ContentCache using CLOCK (second-chance) eviction: - 4096-entry slot array with reference bits - O(1) path→slot lookup via StringHashMap - Hot files (recently searched/read) stay cached - Cold files evicted on sweep, readContentForSearch falls back to disk - Prior content duped before cache eviction to preserve #252 errdefer word_index restoration on OOM Expected: peak RSS drops from ~1.7GB to ~200MB on large repos while maintaining identical query behavior (cache misses served from disk). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThreshold: 10.00%
|
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.
Summary
Replace
Explorer.contents: StringHashMap([]const u8)(unbounded, 1.7GB peak RSS) with a fixed-size CLOCK eviction cache (4096 entries, ~200MB bounded).StringHashMap(u32)path-to-slot mappingreadContentForSearchfalls back to disk read on cache missBehavioral notes
releaseContents()now clears the cache instead of freeing a HashMapTest plan
ContentCache basic put/get/removeContentCache update existing entryContentCache clear resets stateContentCache evicts under pressure(fills 4596 entries, verifies bounded count)🤖 Generated with Claude Code