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: runaway memory via VSCode #60711
Comments
Thank you for the report, especially the repro, and sorry for the regression. You can fix this temporarily by reverting to gopls@v0.11.0.
Testing this out, it seems like the same exact symptoms as #60621, which is that the new analysis driver churns through an enormous amount of memory during its recursive package analysis. This only happens when certain files are open (because we only analyze open packages), and we're not entirely sure what is special about these packages or their dependencies. In this case, the one that did it for me was I have confirmed that our tentative fix in https://go-review.git.corp.google.com/c/tools/+/501207 mostly resolves the issue: it takes analysis perhaps 30s to finish (I didn't time it precisely), but then is fast, and subsequent restarts use under 1GB of memory. Although I believe this is essentially a dupe of #60621, I'll leave this open to track the fix in this specific repository. CC @adonovan |
Fantastic! Thanks for the quick response! I concur that opening specific files seems to make it worse. The one that seemed to trigger the behavior most aggressively for me was pkg/installmanager/installmanager.go in case that helps your sleuthing :)
Figured out how to turn this off, btw, so I have a full workaround. |
Can you share how you turned off the forceful upgrade? |
Sure!
I'm told the json version is: |
@2uasimojo Thank you! I think I also encountered this gopls/vscode sluggishness... |
@David-Mao we think we understand the bug in this case, and it is specific to particular packages in particular repos. Can you share any details about what you are experiencing? Are you working in an open-source repository that we could investigate? |
Using contrib/cmd/hiveutil/main.go, I confirm that this is a dup of #60621, and that the pending fix in https://go.dev/cl/503195 is effective. (It's a different approach from CL 501207, since abandoned.) The new binary loads the repo in 30s / 8GB peak with a cold cache, then 10s / 1GB peak with a hot cache. Steady state memory drops to 100MB. Closing as dup. |
Can confirm fix via 0.12.3 -- thank you! |
I have a stupid question regarding 0.12.3 and I don't want to open an issue for that so here I am: After upgrading to 0.12.3, during my typing, it keeps refreshing things like Many thanks! |
Not a stupid question! I suspect you are seeing the issue reported at https://github.com/golang/vscode-go/issues/2831, for which we have identified the cause and are working on a fix. In short, certain 'go list' errors cause gopls to enter a crash loop, so it restarts the linting. You might be best off with v0.12.2 for now. Sorry for the inconvenience, and thanks for reporting the problem. If you wouldn't mind, could you share the output of |
I'm glad to but the problem disappeared for now and I didn't figure out how to reproduce it, it's quite sneaky... Will report back if I catch it again! :) |
gopls version
...as installed by default by VSCode (version below)
go env
Operating System
RHEL8:
Go version
Tried with go 1.19.3 and 1.20.4, same results.
What did you do?
top
What did you expect to see?
VSCode operating normally. Been using it for >3y. Used to be when I started it up -- even in this ginormous repo, even with literally dozens of files open -- it would churn for a minute or so and then be responsive to any F12 I could throw at it.
What did you see instead?
Starts sluggish, gets moar sluggisher. Symbols etc. never become responsive to hotkeys. Eventually (within a few minutes) entire system becomes sluggish. Memory usage in tens of gigs before the system freezes and I have to hard reboot. If I catch it when it's merely sluggish and kill the gopls process (and then VSCode so it doesn't come back) the system recovers. If I manually install gopls at 0.11.0 the behavior goes back to what I am used to... but eventually it seems VSCode automatically "upgrades" gopls and the problem recurs.
Tried uninstalling and reinstalling VSCode, same results.
Editor and settings
Editor is VSCode at version:
Was able to reproduce with a fresh install with no settings, just the "go" extension installed.
Logs
I'm afraid these instructions didn't help me understand how to make VSCode add the
-logfile
command line argument. It doesn't seem to be via thegopls
section insettings.json
, at least for any symbol the autofiller knows about.The text was updated successfully, but these errors were encountered: