Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: determine how frequently to reload packages with missing dependencies #36918

stamblerre opened this issue Jan 31, 2020 · 2 comments


Copy link

@stamblerre stamblerre commented Jan 31, 2020

Currently, when a user's package has a dependency that we can't resolve, we try to reload the package on every key stroke. We take care not to re-check it unless the metadata has changed, but it's still expensive to call packages.Load on every keystroke.

I wonder if we might be able to somehow make use of the goimports scanning logic in gopls to do this in a better way. It's possible that we can't do better in GOPATH mode (or in another build system), but I'd think we might be able to do something better in module mode.

@heschik: Is this a reasonable idea, or should we just stick with the current approach?

Copy link

@gopherbot gopherbot commented Jan 31, 2020

Change mentions this issue: internal/lsp/cache: refactor functions that return PackageHandles

gopherbot pushed a commit to golang/tools that referenced this issue Feb 7, 2020
Now that we build PackageHandles in load, we can simplify a lot of our
logic for rebuilding them and reloading metadata.

The only possibly-significant change is the missing imports logic. Now
that we always create package handles in load, we don't have to do the
extra "sameSet" logic. If the package handle hasn't been invalidated
since we last built it, we will keep the benefits of caching it. Otherwise,
it will be rebuilt in load.

Updates golang/go#36918

Change-Id: Ieb45898d248501e3cebdb95c8b518149ba7498e5
Run-TryBot: Rebecca Stambler <>
Reviewed-by: Heschi Kreinick <>
TryBot-Result: Gobot Gobot <>
@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Jun 24, 2020
@stamblerre stamblerre added this to the gopls/unplanned milestone Oct 21, 2020
@stamblerre stamblerre moved this from Critical to Needs Triage in vscode-go: gopls by default Nov 13, 2020
Copy link
Contributor Author

@stamblerre stamblerre commented Nov 13, 2020

At this point, the missing dependencies logic is only used in gopls to determine what types of show message warnings we should show the user. Packages with missing dependencies are only reloaded if we expect their metadata to have changed (package name or import change).

@stamblerre stamblerre closed this Nov 13, 2020
vscode-go: gopls by default automation moved this from Needs Triage to Done Nov 13, 2020
@stamblerre stamblerre removed this from the gopls/vscode-go milestone Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants