Repository navigation
Project only the changed pages; skip cache lookups for unchanged files (#145 M4) - #334
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>
#145 M4) Projection takes its input as pages: each file's facts, and each linker's share for the file it linked (JavaScript, Python, generic). A page is projected again only when its file changed, was extracted or failed, a linker replaced its facts, or its linker linked it again; its content hash then decides whether its fact keys are worked out. Facts outside pages keep the content-defined runs. A node or edge is merged again from its own path's pages, the pages fact_pages lists for it (migration 17, additive), the dirty pages and the facts outside pages, in the merge order of a full pass. Cold maps store exactly what they stored before. A file whose census entry is unchanged since the last map is not looked up in the extraction cache: cache:refs keeps where each file's results are (page and slot, or empty) and which adapters read it, valid while the generation and projection stamp are the last map's. An edited file's paged cache row is now read before its replacement can release the page: the generic linker reused nothing after M3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Advances #145 (milestone M4).
Stacked on #333 (
perf/lazy-extraction-145), which is still open; this PR targets that branch so the diff is M4 alone.A re-map now projects only the pages a change reached, and does not look up unchanged files in the extraction cache. This is about half of M4. The 2× target is not reached: every linker still reads every file's facts through
allFileFacts(). That is the other half, and it is not in this PR (see "What remains O(repo)").What changed
out.pages.fact_rows, as runs were.fact_pageslists for it (one row per page holding a fact about a node it is not named after); the dirty pages; and the facts outside pages. The merge keeps the order of a full pass. An edge into a node from a page that was not read is found by target infact_rows.projection:page). Per map: one brotli row with each page's signature, count and hash, and each linker's publication stamp (projection:pages).cache:refskeeps, for each file, where its results are (page and slot, or empty) and which adapters read it. A file whose census entry is unchanged is neither matched against adapter globs nor looked up.lazyExtractionsretry.cache.looked_upis the number of validity lookups.projection.pages: { dirty, read }is the number of pages projected again and pages decoded.Cold maps are unchanged. Cold maps of
tests/fixtures/{js,python,generic,contracts,database,iac,k8s,delivery,ownership,golden},runtime/andadapters/store identical facts, nodes and edges before and after this change (compared row by row against #333's head). The new merge order differs from the old one only in ways that cannot change any merged node or edge.Compatibility. Migration 17
fact-pagesis additive (breaks: false, always). The run format is renamed (pages48:1), so an older release's runs are never misread: the first map after an upgrade, or after an older release mapped, matches fact by fact once.node scripts/upgrade-test.mjs --count 2(v0.3.3, v0.4.0): 2/2 passed.Measurements
Bench fixture, the bench's 10-file edit. Times are
results[0], in ms; main is origin/main9869568, which does not include #333.10k, alternating:
50k, one run each (load below 8 at the start of each):
The edit is 18% faster at 10k and 22% faster at 50k. The store is 2.5% larger (page prefixes, the two kept rows,
fact_pages).What remains O(repo) (50k, branch run)
allFileFacts()linkFrameworksover all facts; quality, database, k8s, ownership, contracts, di, delivery, wiring, literals, iac and scip each scan every file.projection:pages,cache:refs) read and rewritten whole (O(files)); the runs over facts outside pages (history's per-module facts and linker output no single file owns);checkoutState's git calls.Reaching 2× needs every linker to work from kept per-file output and the change set, so that
allFileFacts()runs only on a cold map. At 50k that would remove most of the 2.8 s in the first two rows. That work, and the remap-cost assertionfacts_read.all.files == 0, are not in this PR. The 10-file edit still decodes every unchanged file throughallFileFacts().Tests
projection-pages.test.mjs(new). Randomized: 12 seeds × 15 edit steps over pages that share nodes, compared row by row with projecting the same input into an empty store. Covers:dirty, and linker stamps that do or do not match.Also run once with 150 seeds, locally.
incremental-projection.test.mjs(new). Randomized map-level test: JS, Python and Java with imports, calls, a shared SQL table,package.jsonandrequirements.txt, with files edited, added and deleted. Each step's facts, nodes, edges and derived facts are compared with a cold map. 2 seeds × 8 steps; also run locally with 25 seeds.remap-cost.test.mjs.empty-extractions.test.mjsalso dropscache:refswhen it simulates a store with legacy rows, because the kept references describe the cache as the last map left it.incremental-*.test.mjsand the JS and Python randomized differential tests pass unchanged.npm test: 4,021 tests, 4,011 pass, 0 fail, 10 skipped.🤖 Generated with Claude Code