Skip to content

Commit

Permalink
gopls/internal/cache: use packageHandles to hold an active package cache
Browse files Browse the repository at this point in the history
Previously, gopls was keeping a common import graph up to date between
snapshots, to optimize re-typechecking open packages. However, this had
several downsides:
 - It required rather complicated accounting
 - Working in package A could get slower after opening package B, if
   package B was in the forward closure of A, since it reduced the
   common import graph.
 - Since imports were constructed a-priori to type checking, we imported
   *all* packages in the forward closure of open packages, even if they
   wouldn't be needed for type checking, inflating the memory footprint.

This CL changes gopls to instead keep track of the active package on the
packageHandle, and invalidate its imports independently of other active
packages. As a result, we can eliminate the complicated importGraph
logic and the associated relationships between open packages. We also
reduce memory by holding on to a minimal set of imports for open
packages.

Change-Id: I82c49bb7002ab748497f34b43844b34176bdef9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614165
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr authored and gopherbot committed Oct 7, 2024
1 parent a30b207 commit c19060b
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 429 deletions.
Loading

0 comments on commit c19060b

Please sign in to comment.