Repository navigation
Decode cached facts only when they are read (#145 M3) - #333
Merged
Merged
Conversation
The Python linker emits its output per module and records what each module's link read in link_refs: the files whose symbols or bindings it looked up, and the layout keys its resolution read (mod:<dotted>, top:<package>, stem:<path>). A re-map links again the changed modules, the modules that read a layout key of a Python file that came or went, the modules that read either, and modules with unused-member evidence; every other module reuses its kept output. Different source roots, an empty link_refs or a semantic index link every module. directories() and packFact/unpackFact move to link-state.mjs and are shared with the JavaScript linker; a packed `path:line` source ref is stored as the line number. The randomized test harness moves to tests/helpers/incremental-link.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aries (#145 M3) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from
perf/incremental-python-link-refs-145
to
main
November 30, 2026 12:36
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.
Advances #145 (milestone M3).
Stacked on #332 (
perf/incremental-python-link-refs-145). I will rebase ontomainonce #332 merges.A map no longer decodes every cached extraction while it validates the cache. Each file's facts are decoded when something asks for them. Every step that still reads every file's facts gets them from one function,
allFileFacts(), and M4 replaces it.What changed
lazyExtractionsinruntime/state/extraction-cache.mjs).partial.allFileFacts()is the isolated consumer. It decodes every remaining reference in page order, so each page is inflated once. It returns the same path-ordered Map thatperFilewas, with the censusis_testrule applied.file_index, adaptercoverage:files), keyed by the link key and by each file's blob, kind, test flag and language.parse_quality: 'semantic'mutation is applied from thesemanticmap.languageCoverageandanalysisCoveragetake the summaries.coverageandanalysison every map innpm test. That temporary assertion is not committed.facts_read: { files, facts, pages, all: { files, facts, pages } }in the map summary. The top level is what lazy reads decoded;allis whatallFileFacts()decoded.all_facts_msphase, which bench.mjs also reports.moduleBy, the eageraddFacts, and the census-order and path-order re-sorts are gone.Audit of
perFileconsumersis_testrule, path orderallFileFacts()inputs,previousFacts)factsByFile)allFileFacts(): JS and Python have global passes over every file (frameworks, member reach, symbol indexes); the others scan every fileallFileFacts()allFileFacts()until M4Compatibility. No migration and no schema change. Older releases ignore the
coverage:filesrow. A store without that row, or with a different key, works its summaries out once.node scripts/upgrade-test.mjs --count 2(v0.3.3, v0.4.0): 2/2 passed.Measurements
Deterministic counters, bench 10k fixture, the bench's 10-file edit:
files/facts/pagesall.files/all.facts/all.pagesThe edited files' facts were all freshly extracted, so lazy reads decoded nothing. After a build without this change mapped three 10-file commits, the kept summaries of the 29 distinct files those commits touched were stale, and exactly those were decoded.
Matched bench,
node scripts/bench.mjs --sizes 10k, alternating origin/main and this branch. The branch includes #332. Times areresults[0].incremental, in ms.50k, one run per side:
This PR does not make a re-map faster, as expected for M3 alone. The decode moves out of extraction into
allFileFacts():all_factsplus coverage is 1,873 ms against 1,862 ms on main.link_msis 50–100 ms higher on the branch in every run. An extra round of two runs against Link again only the Python modules a change reaches (#145) #332's branch alone gave the same picture: link 405 against 328, and 543 against 425 ms. CPU profiles over four edits each show no new link-side work; they differ by about 27 ms per edit in total, of which coverage summaries are about 10–15 ms. I read the rest as GC and load noise (load average 5–17), but I have not proven it.What still scales with the repository
allFileFacts(): 1.24 s at 50k, about 0.19 s at 10k. This is the cost M4 must remove, together with making the linkers' global passes work from the change set.Tests
remap-cost.test.mjs: a 60-file project with a 10-file edit.allFileFacts()decodes the other 50 or more.coverageandanalysisequal a cold map's of the edited tree.extraction-pages.test.mjs, ported to the lazy reader:incremental-*.test.mjsand the JS and Python randomized differential tests pass unchanged.npm test: 4,017 tests, 4,007 pass, 0 fail, 10 skipped.🤖 Generated with Claude Code