Repository navigation
Make a re-map cost less for what did not change, and keep the store from growing - #139
Merged
Merged
Conversation
…rom growing A map whose inputs are all unchanged returns the last complete result after the census. The constant-use scan of the literals adapter reads only files whose content changed. A replaced discovery or history cache blob is deleted, and the write-ahead log is folded into the database after each map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emap # Conflicts: # docs/benchmarks.md
… drop (#88) A run:true SCIP language that was missing, timed out or failed fell back to lexical facts but map:last was saved, so the next map returned the lexical result after the tool was installed. Such a map is no longer saved. casDrop now keeps a blob another cache entry still references. The progress test changes a file first, since an unchanged tree is now answered without work. Refs #88 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
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.
Design
Measured on nopCommerce (pinned in
scripts/corpus.json, 24,609 adapter-file pairs, 96 MB of source; cold map, no-change re-map, three committed one-file edits; machine shared, load average about 19, so times are upper bounds). A one-file re-map onmain:literalsconstant-use scan re-reading every source file (0.6 to 3.4 s, 2.6 to 7.2 s in the slowest run), plus per-repository fixed costs: census about 1.4 s, reading all cached facts 0.6 s, linking 0.6 s, hashing every fact in projection 0.6 s, derived facts 0.4 s. A map with nothing changed repeated all of that (9 s).discoverwrote its 1.8 MB result blob under a new digest and never removed the superseded one.Cause. Three things that scale with the repository, not the change: (1) a map with no change re-ran link, discovery and projection; (2) one adapter's whole-repository
discoverwas cached on the blobs of all files it reads, so any edit re-read all of them; (3) caches replaced their blob without deleting the old one, and nothing checkpointed the WAL.Change.
unchanged: true, 0 re-extracted) after the census. The checkout notice and scope notices are worked out again. A map with failures, or a degraded batch, is never skipped.literalsdiscover caches, per file infile_index(replaced in place, so no growth), what a scan of that file found, valid for its blob and a digest of the names looked for. A one-file edit rescans one file; a change to the set of constant names rescans all.discover_filesin the summary reportsscannedandcached.discover:*orhistory:cacheblob is deleted when it is still the cache's own (label, no run).PRAGMA wal_checkpoint(TRUNCATE)runs at the end of a map.Rejected.
VACUUM: the store is 255 MB for 96 MB of source here (2.7 times), inside SC-002's 3 times, andVACUUMgained nothing (the freelist was 0).file_indexrows of deleted files: scoped maps would delete rows outside their scope.file_indexalready has the right key.graphPairnow skips these rows (adapterending:uses).Summary
Makes an unchanged re-map cost the census, a one-file re-map no longer rescans every file for constant uses, and the store stops growing with each re-map. It meets scenarios 3, 4 and 5; scenarios 1 and 2 are only partly met (see the map).
Refs #88 (first part; incremental linking, compact edges and the benchmark gate follow in a second PR)
Scenario map
tests/unit/graph/delta.test.mjs(existing, passes),remap-cost.test.mjs"a one-file edit rescans one file ... equals a cold map"; nopCommerce after three edits: fact and edge digest of the incremental store equals that of a cold mapmap:lastand map in full once. The upgrade test is in the full runscripts/bench.mjsis unchangedTesting steps
Tests (new, each failed before the change), in
tests/unit/graph/remap-cost.test.mjs:unchanged, same generation and counts), and a changed file does the full work again;discover_files), a new use is seen, and the stored uses equal a cold map of the final tree;Checks: the full
npm testunder the lock ran 3,638 tests: 3,627 passed, 9 were not counted as pass or fail (skipped or todo), 2 failed. One is the knownrequireHumanTTY; the other wassemantic.test.mjs(a skipped map did not see a rewritten SCIP index), which this change then fixed by stamping the index files into the skip key (inputson the scip adapter). Re-run after the fix: the SCIP, remap-cost, delta and mapped-scopes files, 43 of 43 pass. One input outside the census, the scip index, needed this; an adapter that reads other files outside the census must declare them the same way.Follow-up issues
Review fixes
map:last, so installing the tool takes effect on the next map (test:a map with a blocked indexer is not reused once the indexer is installed).casDropkeeps a blob another cache entry still references (test:dropping one adapter's previous blob keeps a blob another adapter still references).origin/main(conflict indocs/benchmarks.md, both sections kept).Performance & Security & Data Privacy
Performance: as measured above. Security and privacy: the cache blobs deleted are the cache's own (label and no run), the skipped-map summary is the one already stored in the project's own store, and nothing leaves the machine. The measurements are of public repositories only.
Feature flag
None. No behaviour change in the graph (equal to a cold map);
unchangedanddiscover_filesare added summary fields.🤖 Generated with Claude Code