Repository navigation
Link incrementally, stop opening unchanged files, and store edges compactly (#88) - #144
Merged
Merged
Conversation
…ration (#88, FR-003) The edges table kept a text id that repeats type, src and dst, a primary-key index on it and a src index beside the dst index. It is now a WITHOUT ROWID table keyed by (src, type, dst) whose id is a virtual generated column, so readers (`SELECT * ... ORDER BY id`, `WHERE id = ?`) see the same rows and ids. Migration 3, `compact-edges`, copies existing rows into the new table; it is `breaks: true` because older releases write the id column, so schema_version becomes 3 and the hooks-seen guard holds it while an older session runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…open them (#88) The census stat'ed every file and read the first 4 KB of most of them on every map, the floor every re-map paid. Entries of tracked files git sees unchanged are now kept in file_index (`census:entry`, one row per path, replaced in place) for the rules they were worked out under (globs, test projects, size limit, release); a file with the same blob is neither stat'ed nor opened. The map summary reports `census.cached`. graphPair skips every builder cache row (an adapter id with a colon), not only `:uses` ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re (#88, FR-001) The builder gives each linker `incremental`: the paths whose facts differ from those its saved state was computed from, what it saved, the facts a changed path held before, and per-file rows (file_index `<id>:link`) written only when the link succeeds. With no usable state (first map, another adapter set, options or configuration) a linker links in full. - generic: each file's link result is kept with the keys it looked up (module paths, type names, packages, directories, C# names and namespaces, member reach). A file is linked again when it changed or a changed file's answer to one of its keys differs now from before; others replay their kept result. Manifests, type sets and bases, friend assemblies and a SCIP index still link everything (shortcut noted in code). - quality: clones depend only on modules sharing a fingerprint hash; the postings are the reverse index, and modules sharing no hash with a changed file, now or before, keep their clones. The summary's `link` says how many modules each linker linked again. The new test compares every stored row with a cold map after a body edit, a member read from another file, a change to a widely used type, a symbol rename, a broken clone, a manifest change, and files deleted and added (C#, Java, Go, JS). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a 30k-file C# repository the ownership link compiled every CODEOWNERS rule's globs again for every ownable node (minutes of a one-file re-map). Rules are now compiled once, answered once per path, and the answers are kept for the next map while the rules are the same. The build graph's `ownerOf` is memoised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A hash seen in more than MAX_POSTINGS files pairs nobody. A changed file in such a list, over the bound before and after the change, no longer marks the list's other files as affected; on the synthetic tiers, where boilerplate hashes are shared by almost every file, that was nearly every module. A randomised test compares the incremental link with a full one across edits, deletions and additions with lists around the bound (it fails when the before-size check is dropped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generic linker's kept per-file results (the keys each file looked up and the edges it produced) were 1.08 GB on a 30.8k-file C# repository, more than its extracted facts. The rows are now deflated (what files look up repeats across files): the store after a cold map is 3.1 GiB there, below the 3.5 GiB before this series. An unreadable row only means that file is linked again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CHANGELOG (Unreleased, Changed and Migration notes), COMPATIBILITY (a store migration older releases cannot live with), and docs/benchmarks.md with the 50k gate before and after and a 30.8k-file C# monolith (cold, no change, one-file edits, store size). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ink-compact-store
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.
Summary
The rest of #88 after #139 and #140: incremental linking keyed by changed files and the symbols they declare (FR-001), a census that does not open unchanged files, and compact edges with an ordered, breaking store migration (FR-003). On a 30.8k-file C# monolith a one-file re-map goes from 147 s to 25 to 31 s, and a no-change re-map from 4.7 s to 0.6 s. Every incremental result is compared row by row with a cold map (FR-002). Two of the three synthetic gate ratios are still over their bounds; the numbers are below.
Closes #88
Design
Census. A map stat'ed every file and read the first 4 KB of most of them. Now the entries of tracked files that git sees as unchanged are kept in
file_index(census:entry, one row per path, replaced in place). Each entry is valid for the rules it was classified under: globs, test projects, size limit and release. A file with the same blob is neither stat'ed nor opened. The summary reportscensus.cached.Incremental linking. The builder gives every linker
incremental:<id>:link, deflated), written only when the link succeedsWhen there is no usable state (first map, a different adapter set, options or configuration), the linker links in full.
generic: each file's link result (edges, dependency calls, resolved targets, qualifiers, build rejections) is kept with the keys it looked up. Keys are module paths, type names, packages, directories, C# names and namespaces, and member reach. A file is linked again when it changed, or when a changed file's answer to one of its keys is different now (key added, removed or changed). Every other file replays its kept result. Some changes no key covers, so they still link everything: manifests, the set of types or bases a file declares, friend assemblies, and a SCIP index (ashortcut:comment marks this).quality: a module's clones depend only on the modules it shares a fingerprint hash with, and on the length of those hashes' posting lists. The postings are the reverse index. Only modules that share a hash with a changed file, now or before, are paired again. A posting list overMAX_POSTINGSboth before and after the change pairs nobody, so it marks no one.ownership: CODEOWNERS rules are compiled once, answered once per path, and the answers are kept while the rules do not change. This was most of the 147 s on the monolith: the linker recompiled every rule for every node.ownerOfis memoised.Compact edges.
edgesis aWITHOUT ROWIDtable keyed by (src, type, dst).idis a virtual generated column, soSELECT * ... ORDER BY idandWHERE id = ?read the same rows and ids as before, and the separate src index is gone. Migration 3 (compact-edges) copies the existing rows, so no re-map is needed. It isbreaks: true: older releases write the id column, so they refuse a schema-3 store. Their hooks still allow read-only commands, and the hooks-seen guard holds the migration back while an older session is running.Rejected.
fact_ids.Scenario and requirement map
bench.mjs --sizes 50k --gate, table belowtests/unit/graph/incremental-link.test.mjs: nodes, edges, facts and derived facts equal a cold map after each of: a body edit, a body edit in a two-type file, a member read from another file, a change to a widely used type, a symbol rename, a broken clone, a manifest change, and files deleted and added (C#, Java, Go, JS).tests/unit/adapters/quality/incremental.test.mjs: 25 random trees × 4 rounds of edits, deletions and additions, with posting lists around the bound.delta.test.mjsandremap-cost.test.mjspass unchangednode scripts/upgrade-test.mjs --count 5: 5/5 (v0.3.0 to v0.4.0, schema 1 → 3, the old hooks still allowecho hiandgit status). New migration test intests/unit/state/migrations.test.mjslinkreports{relinked, modules}. Monolith hub edit: generic linked 1 of 28,990 files againEDGES_DDLbench.test.mjsMeasurements
Apple M5 Max, Node 26.13. The machine was shared, with load average 2 to 16, so times are upper bounds.
MewsSystems/mews (30.8k files, lexical C#, 210,713 nodes, 1,085,342 edges),
unknot mapfrom the CLI. Themaincolumn is the run reported on #88.Enterprise.cs(comment appended, committed)du .unknot)bench.mjs --sizes 50k --gate:Testing
node --test tests/unit/scripts/bench.test.mjs tests/unit/graph/delta.test.mjs: 3/3 passnpm test: 3,670 tests, 3,654 passed, 9 skipped, 7 failed. All 7 failures are intests/unit/daemon/remote.test.mjswith "CA signature digest algorithm too weak". They fail the same way onmainwith the local Node 26 / OpenSSL and are unrelated to this changenode scripts/upgrade-test.mjs --count 5: 5/5tests/unit/graph/incremental-link.test.mjs,tests/unit/graph/census-cache.test.mjs,tests/unit/adapters/quality/incremental.test.mjs, and the compact-edges case intests/unit/state/migrations.test.mjsTwo existing assertions in
migrations.test.mjschanged. They said "no applied migration breaks older releases" (schema_version'1'). A breaking migration makes that false by design, so they now expect '3'. The second also checks thatfacts-digestalone stays at compat level 1, so its original point still holds.Migration notes
The first open by this release rebuilds the edges table, which takes a few seconds on a large store. Releases before this one cannot write the store afterwards. Each linker links in full once, then incrementally. This is in the CHANGELOG migration notes and COMPATIBILITY.md.
Follow-up
genericby keying the index's verdicts per file.🤖 Generated with Claude Code