Skip to content

resolver: scan only unresolved edges in attributeGoBuiltins#275

Merged
zzet merged 2 commits into
mainfrom
perf/attribute-go-builtins-scan
Jul 9, 2026
Merged

resolver: scan only unresolved edges in attributeGoBuiltins#275
zzet merged 2 commits into
mainfrom
perf/attribute-go-builtins-scan

Conversation

@zzet

@zzet zzet commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • attributeGoBuiltins only ever rewrites an edge whose target has the bare unresolved:: prefix — every other edge it examines is a guaranteed no-op — but it scanned every edge of 11 candidate kinds (resolved and unresolved alike) via 11 separate EdgesByKind calls.
  • Replaces that with one scan over EdgesWithUnresolvedTarget() (backed by the existing is_unresolved index), filtering to the relevant kinds in Go afterward.

Test plan

  • GOWORK=off go build ./...
  • GOWORK=off go test ./internal/resolver/...
  • golangci-lint run ./internal/resolver/... — 0 issues
  • Verified on a real store: ran the old (11x EdgesByKind) and new implementations against two identical copies of the same store — same materialized builtin::go:: nodes (23), same rewritten edges (18,982), and an identical SHA-256 hash over the FULL edge set (2,571,420 edges, not just the builtin-targeted subset)

zzet added 2 commits July 9, 2026 01:43
attributeGoBuiltins only ever rewrites an edge whose target has the
bare unresolved:: prefix — every other edge it examines is a
guaranteed no-op. It scanned every edge of each of 11 candidate kinds
(resolved and unresolved alike) via 11 separate EdgesByKind calls.
EdgesWithUnresolvedTarget's is_unresolved index already collects the
exact superset in one indexed scan, so filtering to the relevant kinds
in Go afterward is equivalent but skips every already-resolved edge.

Verified on a real store: running the old and new implementations
against identical copies produces byte-identical results — same
materialized builtin nodes, same rewritten edges, and an identical
hash over the full edge set (not just the builtin-targeted subset).
Only ~2% of candidate names ever match a Go builtin (18,982 of
823,563 in a real store), but the function called r.fromIsGo (which
can fall back to a graph node lookup) and unconditionally computed
r.callerRepoPrefix (which always does one) before ever checking
whether the name was a builtin at all — paying for both on the ~98%
that were always going to return "" anyway.

Adds isGoBuiltinName, a repo-prefix-free membership check mirroring
goBuiltinTarget's own three map lookups, and runs it first. Also
reorders the language-origin check to try e.FilePath's free
struct-field suffix test before r.fromIsGo — the same condition
(&& is commutative), just evaluated cheapest-first.

Verified on a real store: old and new implementations produce an
identical whole-graph edge-set hash (2,571,420 edges). Timing for
this pass: 15.75s -> 6.95s (on top of the prior EdgesWithUnresolvedTarget
change, 25.02s originally).
@zzet zzet merged commit 94aed9f into main Jul 9, 2026
9 checks passed
@zzet zzet deleted the perf/attribute-go-builtins-scan branch July 9, 2026 06:08
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