[Repo Assist] perf: upgrade analysis cache from FIFO to LRU eviction#246
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[Repo Assist] perf: upgrade analysis cache from FIFO to LRU eviction#246github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
When a cache entry is hit, delete and re-insert it so it moves to the back of the Map's insertion-order. This means the entry deleted on eviction is always the least-recently-used rather than the first inserted, which better retains hot files (e.g. the file a developer is currently editing) across larger workspaces. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
The analysis result cache in
MetricsAnalyzerFactory.analyzeFilepreviously used FIFO eviction: when the cache was full, the first-inserted entry was deleted, regardless of whether it had been accessed recently.This changes it to LRU (Least Recently Used) eviction by deleting and re-inserting a cache entry on every hit, which moves it to the end of the
Map's insertion order. The entry at the front is then always the least recently used, so eviction removes the entry least likely to be needed again.Why this matters
In a typical VS Code workflow a developer cycles between a small number of open files. With LRU eviction those files stay warm in the 20-entry cache even in a large workspace, whereas with FIFO they could be evicted by infrequently-opened files that happened to be visited first.
Changes
src/metricsAnalyzer/metricsAnalyzerFactory.ts: on cache hit,delete+setto promote to MRU position; updated JSDoc comment.Test Status
npm run compile✅ no errorsnpm run lint✅ no errorsnpm run test:unit✅ all 35 existing tests passNo new tests in this PR (cache-behaviour tests are covered in the companion PR
repo-assist/test-coverage-improvements-2026-04-07).