Skip to content

perf(explore): precompute call-graph reverse adjacency#651

Merged
justrach merged 1 commit into
release/0.2.5828from
perf/callgraph-radj
Jul 4, 2026
Merged

perf(explore): precompute call-graph reverse adjacency#651
justrach merged 1 commit into
release/0.2.5828from
perf/callgraph-radj

Conversation

@justrach

@justrach justrach commented Jul 4, 2026

Copy link
Copy Markdown
Owner

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 in ensureCallGraph beside 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_search queries A/B'd between binaries with CODEDB_NO_SEARCH_CACHE=1, payloads byte-identical on all 8.

Numbers (this repo, uncached, 20 repeats, steady tail)

base head
median 1900µs 1400µs (−26%)
mean 2475µs 1438µs
min 1900µs 1400µs

Head's min==median shows the variance collapse from removing the per-query allocation storm. Benefits every uncached codedb_search/codedb_context keyword search on graph-bearing repos.

zig build test: 23/23 steps, 869/873 (4 platform skips). e2e: 20/20.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 93830 94768 +1.00% +938 OK
codedb_changes 10797 11487 +6.39% +690 OK
codedb_context 293245 289749 -1.19% -3496 OK
codedb_deps 381 383 +0.52% +2 OK
codedb_edit 36078 35940 -0.38% -138 OK
codedb_find 2754 2775 +0.76% +21 OK
codedb_hot 26559 25536 -3.85% -1023 OK
codedb_outline 18085 19098 +5.60% +1013 OK
codedb_read 13184 14775 +12.07% +1591 NOISE
codedb_search 88185 86663 -1.73% -1522 OK
codedb_snapshot 74684 68888 -7.76% -5796 OK
codedb_status 9208 9871 +7.20% +663 OK
codedb_symbol 59425 60373 +1.60% +948 OK
codedb_tree 42222 12581 -70.20% -29641 OK
codedb_word 12377 12093 -2.29% -284 OK

@justrach justrach merged commit c516b35 into release/0.2.5828 Jul 4, 2026
2 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant