perf(explore): precompute call-graph reverse adjacency#651
Merged
Conversation
queryGraphDistances rebuilt the reverse adjacency from the edge list on every scored search — O(E) ArrayList allocations per query, measured at 118µs/call (~43%) of an uncached ranked search on this repo. Build it once in ensureCallGraph beside the forward adjacency and reuse it. Identical output by construction: the per-call rebuild iterated the same edge list in the same order, so list contents and BFS visit order are unchanged. 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.
Round-2 item 2 (from the 4-agent speedup survey; measured recommendation from the kwloop analysis).
What
queryGraphDistances— on the hot path of every scored search (the graph-distance rerank boost) — rebuilt the reverse adjacency from the full edge list on every query: O(E) ArrayList allocations per call, measured at 118µs/call (~43% of an uncached ranked search's kwloop-visible cost on the bench corpus). The reverse adjacency is query-independent by construction, so build it once inensureCallGraphbeside the forward adjacency (CallGraph.radj), and let queries reuse it.Output parity
Identical by construction: the per-call rebuild iterated the same edge list in the same order, so list contents — and therefore BFS visit order, distances, and scores — are unchanged. Verified empirically: 8 symbol-shaped
codedb_searchqueries A/B'd between binaries withCODEDB_NO_SEARCH_CACHE=1, payloads byte-identical on all 8.Numbers (this repo, uncached, 20 repeats, steady tail)
Head's min==median shows the variance collapse from removing the per-query allocation storm. Benefits every uncached
codedb_search/codedb_contextkeyword search on graph-bearing repos.zig build test: 23/23 steps, 869/873 (4 platform skips). e2e: 20/20.🤖 Generated with Claude Code