Repository navigation
perf(resolution): reuse exact-name local binding checks - #2871
Closed
luojiyin1987 wants to merge 1 commit into
Closed
luojiyin1987 wants to merge 1 commit into
luojiyin1987 wants to merge 1 commit into
Conversation
luojiyin1987
marked this pull request as ready for review
October 24, 2026 00:42
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Oct 27, 2026
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Oct 27, 2026
colbymchenry
pushed a commit
that referenced
this pull request
Oct 27, 2026
…ch — graph byte-identical matchByExactName asked isLocallyBoundJsName for every cross-file candidate of a bare JavaScript or TypeScript call, though the answer depends only on the reference's name and file, which are the same for every candidate. The helper memoizes it per file and name, but each call still built the key and read the memo. The answer is now kept in a lazy local for the one match, at the same place in the filter, so candidates, order, scoring and confidence are untouched. Validation: fresh indexes of codegraph's own source, excalidraw, vben, express and zod dump byte-identical to main's (nodes, edges with their metadata, unresolved refs, files), and express stays identical through sync after a JS file is added, edited and deleted. A CPU profile of indexing codegraph's own source (all threads, two runs per side) puts isLocallyBoundJsName's self time at 150-173 ms on main and 45-46 ms here; the scans it guards (bindsAtSites) are unchanged. Whole-index CPU on vben, 10 interleaved runs, moves less than its noise. The PR's 8 tests pin the matcher's behaviour and pass here and on main. Original PR #2871 by @luojiyin1987. Fixes #2870 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thank you, @luojiyin1987! This landed as #2934 with you as the commit author: |
inth3shadows
added a commit
to inth3shadows/codegraph
that referenced
this pull request
Oct 29, 2026
Brings 4955eac..787eafb (colbymchenry#3014, colbymchenry#3017, colbymchenry#3020, colbymchenry#3018, colbymchenry#3023). Clean auto-merge. README: drop colbymchenry#2871 (closed upstream; colbymchenry#2934 merged in its place, and name-matcher already matches upstream).
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.
A bare JS/TS call can check the same local binding for every exact-name candidate.
The helper memoizes its answer, but each call still builds a key and reads the cache.
matchByExactName()now stores that Boolean lazily for one invocation.The filter position and candidate order stay the same.
The CodeGraph snapshot at
9c4794d6reduces local-binding checks from 387,362 to 15,392.Exact-name calls remain 123,724. Candidate visits remain 1,209,451.
Filtered candidates remain 52,544. Scoring calls remain 2,559.
Import candidates already leave the pool before ranking; this PR adds no import filter.
Validation
nodes.updated_at.Five alternating pairs follow one warmup per arm and resolver mode.
Positive paired savings favor this branch.
CPU means process user time plus system time, including worker threads.
Median paired wall savings are 1.444 s with one resolver thread and 0.243 s with two workers.
The pooled batch-stage median changes from 12.726 s to 12.738 s.
An earlier execution period showed different timing directions.
The repeated-check reduction is confirmed. A stable whole-index speedup is not established.
Reproduce
9c4794d694c62d343e43f29f2a76f576ed8b0e99and this branch separately withnpm ci && npm run build.git archive.9c4794d6, ESLint5c8c2417, and validator.jsce010143for the graph comparison.node --liftoff-only dist/bin/codegraph.js init --yes <fresh-directory>from each build.nodes,edges, andunresolved_refsrows. Normalize onlynodes.updated_at.codegraph syncafter each change and compare again.CODEGRAPH_KERNEL=0for both arms. SetCODEGRAPH_NO_PARALLEL_RESOLVE=1for the single-thread mode.CODEGRAPH_RESOLVE_WORKERS=2andCODEGRAPH_PARALLEL_RESOLVE_MIN=0for the pooled mode.The benchmark uses Linux/WSL2, Node 24.15.0, WASM extraction, and
--liftoff-only.Only resolution uses the single-thread setting. Extraction can still use workers.
The default size limit skips five large CodeGraph files, including
name-matcher.ts.There are no Windows or macOS performance measurements.
Closes #2870. Related: #2829.