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/cmd/gopls: overlays cause go/packages to perform giant "go list" query #32457
Comments
I'd be happy to work on this if I could get some direction on the expected behavior in this case. |
The similar issue reproduces in // Do another pass now that new packages have been created to determine the
// set of missing packages.
for _, pkg := range response.Packages {
for _, imp := range pkg.Imports {
pkgPath := toPkgPath(imp.ID)
if _, ok := havePkgs[pkgPath]; !ok {
needPkgsSet[pkgPath] = true
}
}
} |
Change https://golang.org/cl/181123 mentions this issue: |
This change marks the overlay for a saved file as "on disk". This will reduce the number of overlays we provide to go/packages, which can be expensive. Updates golang/go#31796, golang/go#32457 Change-Id: I8e69503ab80bba29caf4e42491d87e643bf17f1a Reviewed-on: https://go-review.googlesource.com/c/tools/+/181123 Reviewed-by: Ian Cottrell <iancottrell@google.com> Reviewed-by: Peter Weinberger <pjw@google.com>
I had ~60 go files open in gopls. None of them had any unsaved changes (i.e. bytes on disk matched bytes in gopls memory). I noticed when opening a new file in my editor gopls was taking a long time. I tracked it down to the overlay logic in go/packages.
Here is roughly what happened.
foo.go
in a previously unopened package.file=foo.go
query and passes an overlay that includes all 60 files.processGolistOverlay()
it appends a new package to response.Packages for each overlay file's packageaddNeededOverlayPackages()
performs a "go list" call for all items in needPkgs, which takes 3 seconds in my case.I don't fully understand the package overlay stuff, but here are my observations:
/cc @matloob @stamblerre
The text was updated successfully, but these errors were encountered: