-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: high CPU & memory for minutes in "Saving foo.go: Getting code actions from "Go" ..." #57707
Comments
Similar experience. Saving whilst not having a go.mod file present grinds to crawl. |
Well, I have go.mod files. |
Gopls is generally resource hungry on large (or even medium large) workspaces. Furthermore, it is sensitive to which directory you open. Couple questions:
From that profile, it looks like the typical parsing / typechecking / gc slowness, so I'm not sure there's a solution for you with the current execution model. The issue @renthraysk cited is a known problem related to scanning files, but that doesn't seem to be the cause of what you're experiencing. @adonovan and I are working to move gopls off of its monolithic build model, which should finally allow us to solve this category of problem. |
FWIW, in my experience, this can occur when gopls gets into a bad state. It is responsive (enough) working on a project, it gets unhappy, and then saving fails until you kill and restart it. For others experiencing this, you can get past it in a pinch by using the VSCode command palette to do "Save without formatting". And then restarting. :/ |
Hmm, that's... unfortunate. The likely cause of that is that gopls has loaded a bunch of packages (intermediate test variants) for e.g. a references request, and holds on to them until a restart. This particular behavior will be fixed in the next gopls release. |
I had something similar happen last weekend... Gopls was going bonkers taking over cpu on my box while debugging from vscode. I couldn't get back control of the UI and I made the mistake of hard rebooting in the middle (just trying to get my cpu back) which unfortunately bricked my harddrive and OS. I'd had problems with this pet project in the past using gopls. I think it may have had something to do with having a largish bound resource file (but not unreasonable) but that's only a wild guess because I can't repro due to bricking. I should have waited for 1.20 because I was hoping that might help with this.... But I was eager to do a few things... sigh I accepted the risks of using the latest gopls I guess and knew this was a possibility but up to this point have never seen go involved in anything like this before. It could be that my SSD was on the verge of breaking anyhow and the extra activity pushed it over. One thing I did notice before it crashed... swap had been triggered and cpu was aggressively trying to swap. I also noticed that gopls seems to leave a bunch of stale folders in /tmp and there were many many in there. Up to this point I had not put effort into managing /tmp. |
Oof, sorry about that @joel-rieke It sounds like there may be something we don't understand going on here, but we are in the process of making major changes to the way gopls executes (https://go.dev/issue/57987), and my hope is that it makes all of these problems go away. |
No worries, this doesn't change my love of programming in go believe it or not. I'll find my way back. And yes, hopefully the new gopls helps! :) |
@bradfitz, do try out gopls@master and tell us what you find. We're close to the v0.12.0 release, which should reduce stable state memory usage by 5-10x for large projects. |
@adonovan I still have this problem when I use the master, especially when I copy the code from other places and there are many errors in it, it will be very slow to save only when there are errors |
I have similar issue when opening and saving projects with VSCode thru SSH running Arch VM, cpu usage will skyrocket to 100%. Tried opening/saving the same project on the host (Windows) and another VM running Ubuntu, and it works fine. (project is very small with few files) any pointer how to debug this? Also similar to #51829 Edit: I figured out that the VM only use the E-Core of my CPU (i7 13700k), disabling the E-core for the vm fix it for me |
@findleyr This looks like an exact dup of the problems were were debugging yesterday due to VSCode's slow processing of glob patterns consisting of very long comma-separated lists of directories (see #60089 and CL 496186), and perhaps also sequential execution of go mod tidy, and the fact that this is done even when the metadata hasn't changed. |
@adonovan let's close this after we cut the release candidate containing our fix. Then it will be easy for people to test, and comment if they can still reproduce the freezing. I am 92% sure this is a dupe, and now fixed. |
We have cut [email protected], which we believe contains a fix for the specific freezing experienced after save in VS Code.
Please comment if you experience otherwise. |
I don't want to jinx it, but so far so good! 🤞 |
Apologies for commenting on a closed issue, but I'm getting this same issue and it's completely crashing my macbook unless I kill the Details: |
Hi @joshghent . Could you please open a new issue, filling out the gopls issue template? |
Bummer... thought this was fixed... On linux it seems fine lately... But haven't tried with latest go1.21.4 -- debugging the same project of mine that caused this behavior. |
Is your gopls up to date @joshghent ? |
It really should be better now: the code actions operation is now essentially a no-op, except for running |
What version of Go are you using (
go version
)?Go 1.19.4
gopls 0.11.0
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?darwin/arm64 Visual Studio Code => ssh to linux/amd64
What did you do?
I'm trying to become a Visual Studio Code + gopls user, trying to break my emacs habit. I use Visual Studio Code on a Mac over SSH to a Linux server, where gopls/etc runs remotely.
A good fraction of the time when I save in VS Code, I see:
For minutes.
Meanwhile, gopls is using 4-8 GB or more of memory and using tons of CPU.
perf top
says:What did you expect to see?
Faster, I guess.
What did you see instead?
Slower than it seems it should be.
Is this a bug?
I don't know how to go about debugging gopls.
The text was updated successfully, but these errors were encountered: