Skip to content

perf(resolution): avoid repeated local-binding checks per exact-name match #2870

Closed

Description

@luojiyin1987

Problem

matchByExactName() checks whether a JS/TS name binds locally for each eligible cross-file candidate.
The check uses the same filename and name throughout one matcher call.
isLocallyBoundJsName() memoizes the answer, but each call still constructs a key and queries the cache.

The #2829 figure of 5.5 seconds covers complete resolveOne calls with exact-match outcomes.
It does not measure matchByExactName() itself.
Import candidates already leave the exact-name pool before ranking.
This issue does not request another import filter.

On CodeGraph at 9c4794d6, temporary probes record 123,724 exact-name calls and 1,209,451 candidate visits.
They record 387,362 local-binding checks. Only 15,392 are the first check within their matcher call.
findBestMatch() runs 2,559 times and takes about 11 milliseconds with probe overhead.
The repeated local-binding check is a measured, narrow target.

Proposed change

Store the Boolean result lazily within one matchByExactName() invocation.
Keep the check at its current filter position.
Preserve candidate IDs, order, strategy priority, scoring, ties, ambiguity, confidence, and import aliases.
Add no global cache or new resolution rule.

Validation

Compare complete nodes, edges, and unresolved_refs after fresh indexing and incremental symbol changes.
Include raw edge metadata in the comparison.
Normalize only the node indexing timestamp.
Run the full suite and five alternating paired benchmarks in both resolver modes.
Report the repeated-check count and measured wall and CPU times separately.

Related: #2829 and #2840.

Activity

  1. colbymchenry commented on Oct 27, 2026

    @colbymchenry
    Owner

    Fixed by #2934 (from #2871, thanks @luojiyin1987): the local-binding answer is now kept for the whole exact-name match, so each match asks once instead of once per candidate. The graph output is byte-identical; it ships in the next release.

  2. added a commit that references this issue on Oct 27, 2026
    0174f80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions