repomap: stop including prompt mentions in the repo-map cache key (fixes repeated full scans on huge repos) - #5556
Open
SnowingFox wants to merge 1 commit into
Open
Conversation
…xes repeated full scans on huge repos) Fixes Aider-AI#5529
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.
Fixes #5529
Problem
On a repo the size of the Linux kernel, every request re-runs the full repo-map scan (~20 min each), making aider unusable. The map is cached, but the cache key in
get_ranked_tags_map()includesmentioned_fnames/mentioned_identswheneverrefresh="auto"is active:Those prompt-derived values change on every request (the user mentions different files/identifiers each turn), so every request misses the cache and re-runs the expensive scan, even though the file set and file contents are unchanged.
Fix
Build the cache key only from the things the expensive scan actually depends on: the file set (
chat_fnames+other_fnames) and the token budget.mentioned_fnames/mentioned_identsonly affect per-request ranking personalization insideget_ranked_tags(); they do not change the underlying scan. Leaving them out of the key means the scan result is reused across prompts for an unchanged file set.This matches the existing
refresh="files"behavior, which has never put mentions in the key, and is consistent with the "auto" refresh intent: once a map is expensive to build, reuse it until the file set changes.Verification
Added
tests/basic/test_repomap.py::test_repo_map_auto_cache_not_polluted_by_mentions. It arms therefresh="auto"cache (simulating a slow first scan viamap_processing_time) and asserts that a second request with different mentioned files/identifiers does not run the uncached scan again:The test fails against
main(the second request re-runs the scan) and passes with this change. The existing repo-map tests (test_repo_map_refresh_files,test_repo_map_refresh_auto) are unaffected.Notes
This is a small, localized change to the repo-map cache only; it does not touch other subsystems. No other open pull request in this repo is related.