perf(index): word-index persist — integer doc remap + chunked hit writes#650
Merged
Merged
Conversation
WordIndex.writeToDisk resolved every posting's disk file id through a StringHashMap keyed by the full path — one wyhash of the whole path string per posting, millions of times on large repos, flagged as the dominant CPU term of the 840ms word.index persist in #475. doc_id → disk_id is a pure integer remap (path_to_id keeps paths unique), so build a []u32 once in the existing doc-table walk and index it per hit. Hits are also batched into 4KB chunks instead of one 8-byte writeAll each. Output is byte-identical (cmp of word.index written by old and new binaries on the same project), including error.InvalidData for postings that reference stale doc slots. zig build test 23/23 steps green; test-index 174/174. End-to-end cold snapshot on a 2000-file synthetic corpus: 4.90s -> 4.78s — the big win case (#475's long node_modules paths × repo-scale posting lists) scales with path length and posting count, which this corpus intentionally understates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
justrach
added a commit
that referenced
this pull request
Jul 5, 2026
Bump semver + npm to 0.2.5828 and round out the changelog entry with the six commits that landed after the draft was written: searchSymbols binary-insert + total-order tiebreak (#647, #649), word-index persist integer remap + chunked writes (#650), call-graph reverse adjacency precompute (#651), snapshot dual-write clone (#652), ranked-search line-offset resolution (#653), and scripts/bench-ab.sh (#654). No code changes beyond the version strings + CHANGELOG. Co-Authored-By: Claude Sonnet 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.
First of the write-path items from the perf sweep (the load path got its 3× in #524; writes never had a pass).
What
WordIndex.writeToDisklooked up every posting's disk file id viadisk_path_to_id.get(path)— a wyhash of the full path string per posting, millions of times on large repos. #475 flagged the 840ms word.index persist on react; this lookup is its dominant CPU term.doc_id → disk_idis a pure integer remap (path_to_idkeeps paths unique), so a[]u32built once in the existing doc-table walk replaces the per-posting hash. Hit records are also batched into 4KB chunks instead of one 8-bytewriteAlleach.Quality
cmpofword.indexwritten by old vs new binaries on the same project — identical, includingerror.InvalidDatasemantics for postings referencing stale doc slots.zig build test23/23 steps green;test-index174/174.node_modules-style paths at repo scale).🤖 Generated with Claude Code