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
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