[tools] gopls/internal/golang: record implicit deps in the decl graph

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Sep 25, 2026, 7:11:07 PMSep 25
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Madeline Kalil, Alex Putman, Ingo Oeser, golang-co...@googlegroups.com

Gopher Robot submitted the change

Unreviewed changes

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
gopls/internal/golang: record implicit deps in the decl graph

declGraph becomes a struct with two edge sets. An explicit edge u -> v
means u's declaration refers to v by name in the source. An implicit
edge u -> v has no such reference, but v must move with u anyway
because the language couples their declarations: a named type to its
methods, and the constants of an iota group to one another. The iota
group is linked in a cycle, so reaching any constant reaches the whole
group in O(n) edges rather than O(n^2).

computeMovingSet now walks precomputed edges instead of calling
implicitDependencies, which rescanned the enclosing block for every
constant. That function is deleted, along with the benchmark added to
measure it. Moving set for an n-constant iota block:

n before after
10 5.9µs 1.3µs
100 333µs 13.6µs
1000 28.9ms 155µs

Memory at n=1000 drops from 51.8MB to 93KB. Growth is linear again,
though about 2x the pre-regression constant, since every constant is now
a graph node with its own edge set.
Change-Id: Ib3ba842a233f30422395259bae5eec48ea3dc44a
Reviewed-by: Madeline Kalil <mka...@google.com>
Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
Files:
  • M gopls/internal/golang/move_decl.go
  • D gopls/internal/golang/move_decl_test.go
Change size: L
Delta: 2 files changed, 75 insertions(+), 230 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ib3ba842a233f30422395259bae5eec48ea3dc44a
Gerrit-Change-Number: 838166
Gerrit-PatchSet: 4
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Ingo Oeser <night...@googlemail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages