-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: extreme slowdown when using VSCode Go + gopls #43127
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
Comments
This is a perfect write up of what is happening to me as well. The only differences/additions I may add are:
If I can be of any help providing my system information or with debugging anything, please let me know. |
@jeremywiebe Thanks for the report. I will transfer this to the gopls issue tracker for further investigation by gopls devs. @zkmoney It sounds like a different workload, so it's possible that the underlying issue is different while the symptom is similar. Can you please open a separate issue, with the gopls trace? https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code |
The go command should never invoke git on the current module -- it's aware of it only as a directory, not as a VCS repository. If you look at the working directory of the git command, you should find that it's running in the module cache somewhere. Given the behavior you're seeing, the go command is trying to resolve an import that is not in any module currently required by the main module. It will use git to do that if the import path is excluded by GOPRIVATE/GONOPROXY, or if it's just not available from proxy.golang.org. The trigger is probably a change to an import statement, either manually or via an autocomplete, that causes it to search in some very large module. (That could even be an older/cached version of the main module, I'm not totally sure.) If I'm right, some recent changes I made to gopls to avoid the network could be very helpful here. Could you try gopls at master? See https://github.com/golang/tools/blob/master/gopls/doc/user.md#unstable-versions. |
I've filed a new issue with this at #43181 Hello, I experience similar issues to OP. I work in a large repo (hundreds of packages) I observe a dialog box with My go env:
My go-specific VSCode settings:
My gopls version:
In my Let me know if I can provide a more useful trace.
When I switch to using All settings and configuration are unchanged, other than using New gopls version information:
Trace output:
|
@denbeigh2000: Do you mind opening a separate issue and including the output of running |
Thanks for the explanation @hyangah. I tried |
@jeremywiebe Thank you for updating the status! The new version of |
Please review the documentation before filing an issue.
Helpful pages include:
Please answer these questions before submitting your issue. Thanks!
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogo version go1.14.13 darwin/amd64
gopls -v version
to get version of Gopls if you are using the language server.golang.org/x/tools/gopls v0.5.5
golang.org/x/tools/gopls@v0.5.5 h1:YBLs2WCwxx6mBF98Y6/mDIpKhP4Dt4Dz2q6LnMRBpDw=
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders1.51.1
e5a624b788d92b8d34d1392e4c4d9789406efe8f
x64
go env
to get the go development environment detailsShare the Go related settings you have added/edited
Describe the bug
Lately, when working in our Go repo with VSCode, it is responsive for the first while (minutes) but after I've worked a bit and done a few saves, CPU load really spikes. I haven't completely nailed down why, but I suspect that it partly due to
gopls
invokinggo list
which forks out togit
. Quite often my Activity Monitor lists 2git
processes using quite a but of CPU time.I've captured
pstree
output for the VSCode process showing the twogo list
andgit
sub-processes. Thesegit
processes last quite a while and appear to block file saves from completing (for example, as I write this bug, VSCode has been trying to save a.go
file for at least a minute).Once this
go list
/git
process happens, it seems like it enters a loop and never completes.go list
andgit
just keep getting run long after I VSCode has been inactive (although the "Saving..." message is still visible in the bottom right (see Screenshots section).pstree output
Trace output
gopls
logs a bunch of stuff, but I've included the parts of the trace that seem relevant. Happy to gather more if needed.Steps to reproduce the behavior:
.git
dir that is 7.5 GB!). Note also that the entire repo is in a single Go module (we have onego.mod
at the root of the monorepo)..go
file (it doesn't seem to matter which/where), make some code changes, save, make more changes, save. After a whilegopls
starts invoking (I suspect on Save)go list -modfile...
which in turn invokesgit for-each-ref
). This causes a downwards spiral of performance and slow saves.Screenshots or recordings
It's really common for me to see this "Saving..." dialog when working with VSCode (and it blocks saving for seconds to minutes each time).
The text was updated successfully, but these errors were encountered: