Skip to content

[Repo Assist] perf: upgrade analysis cache from FIFO to LRU eviction#246

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/perf-lru-cache-2026-04-07-75018df41e67a7cc
Draft

[Repo Assist] perf: upgrade analysis cache from FIFO to LRU eviction#246
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/perf-lru-cache-2026-04-07-75018df41e67a7cc

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 7, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

The analysis result cache in MetricsAnalyzerFactory.analyzeFile previously 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 + set to promote to MRU position; updated JSDoc comment.

Test Status

  • npm run compile ✅ no errors
  • npm run lint ✅ no errors
  • npm run test:unit ✅ all 35 existing tests pass

No new tests in this PR (cache-behaviour tests are covered in the companion PR repo-assist/test-coverage-improvements-2026-04-07).

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@7c7feb61a52b662eb2089aa2945588b7a200d404

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants