resolver: scan only unresolved edges in attributeGoBuiltins#275
Merged
Conversation
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
added a commit
that referenced
this pull request
Jul 10, 2026
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.
Summary
attributeGoBuiltinsonly ever rewrites an edge whose target has the bareunresolved::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 separateEdgesByKindcalls.EdgesWithUnresolvedTarget()(backed by the existingis_unresolvedindex), 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 issuesEdgesByKind) and new implementations against two identical copies of the same store — same materializedbuiltin::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)