-
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 memory consumption when used with a monorepo #37670
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
There should be some files named |
Thanks. Unfortunately I don't have good news for you. Everything you've posted points to expected behavior -- I don't see any signs of a memory leak or work pileup. It looks like the monorepo is simply too large to work with all at once. If you're only interested in one folder, you can start VS Code in that folder. If you're interested in multiple, you can add them piecemeal to your workspace, but note that most |
I am running in to the same issue described here and it is really annoying because my Linux machine with 8GB memory always runs out of memory and I have to pull out the power plug to be able to actually restart the computer. This often occurs when i am using |
@Jacalz: That sounds like a bug with older versions of It's also possible that you have multiple versions of |
@stamblerre: I verified that vscode is using the correct installation and this is the path of it: |
You can confirm the version by running If the memory usage is high with |
Thanks. It indeed does appear like I am using the latest version:
I tried to find the PID files, but I could not find any. I looked in |
What OS are you on? Take a look at the https://pkg.go.dev/os?tab=doc#TempDir docs to see what directory |
I am on Linux. I looks like I just wasn't getting into regions of memory usage that was concidered too much. I did not open the huge monorepo (https://github.com/fyne-io/fyne) and only saw 800MB memory usage due to that. Below are the files that you requested: gopls.3169-5GiB-goroutines.txt I must admit that they were quite hard to get. When I tried for the first time, the memory usage jumped to 4GB and then I restarted, had the system monitor open and ready to kill |
I was able to reproduce a similar profile by simply opening the root of the Fyne project. Most of the memory is being used by the type checker:
That's a little surprising for Fyne which is a relatively small project. My best guess is that the problem is the GL libraries, which generate tens of thousands of lines of cgo. Regardless, I don't see a |
+1 with version |
get worse with sam @ debian in /_ext/gopath/bin |03:24:50
$ ./gopls version
golang.org/x/tools/gopls 0.4.1
golang.org/x/tools/[email protected] h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
sam @ debian in /_ext/gopath/bin |03:32:22
$ uname -a
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
sam @ debian in /_ext/gopath/bin |03:43:33
$ go version
go version go1.13.7 linux/amd64 |
I have 6 projects open in vscode. A gopls process for each is running ranging from 465MB to 900MB. Crazy! |
syzkaller is another Go project which causes gopls on my machine to consume 27GiB RAM. |
i have the same issue . uname -a Linux shenjie-VirtualBox 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux go version : |
Hi everyone, just a quick reminder that just mentioning your Go version and gopls version is not sufficient information to help us debug this further. If you notice issues with gopls consuming high memory,
Thanks. |
@heschik thanks for the quick response! If I understand what you are saying correctly
The |
After looking more carefully at the same profile in the PR I linked above, I see now what @heschik was talking about. Using |
There have been a number of memory improvements in |
Great improvement guys. My memory usage dropped from 9gigs to almost 2gb. |
For me at least, gopls 0.4.4 has been much more parsimonious than previous versions - I'm seeing 1-2GB of memory usage on my monorepo, where before I was seeing 8-10GB. I haven't yet tried running with master; I will try to check that out in the next couple of days and report back. |
Glad to hear that things are working better! There will be more improvements coming in |
I also confirm that it got much better, it became usable with large projects, thank you very much. |
Using I'm working on a monorepo (~40GB in size) and
Gopls now takes quite a little while longer to eat up all my memory but if left unchecked it will do just that. I'm still having to kill it every 3-4 minutes. My solution now is to use a systemd watchdog to kill gopls when memory usage gets too high---not ideal but far better than losing connection to my remote box. |
I am having the roughly the same issues as @rmerry, but on a different repository. Using gopls with https://github.com/fyne-io/fyne results in massive memory consumption that easily climbs up to over 8 gigabytes of memory consumption. It climbs a lot more slowly with the latest releases, but it is still largely unusable sadly :( |
Please file new issues following the steps at https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#memory-usage. Simply reporting that gopls uses a lot of memory, or describing the workarounds you use to kill it, doesn't help us solve the problem. The memory diagnostics might. |
I like this suggestion. Additionally, can we please keep this issue open? I regularly try with the latest gopls code (trying since May of 2020) and this issue is certainly not fixed yet as of the latest code checked into master of gopls, so for now, I'm turning it off in VSCode. Maybe this is just a really hard problem to fix and will take a good long while to fix? Could be that the feature set is too rich and there could be a reduced configuration option for gopls to run in a 'lite' mode. For now, unfortunately, it means I can't use the tool in my development. |
Sorry, no. Every open issue with "memory" in the title immediately becomes a lightning rod for everyone with a complaint, regardless of how similar their problem is to the previous ones, and then we can't untangle who's who. The issue is very hard to fix, but I happen to be working on it now. If you file a new issue with a memory zip I can take a look at whether the work I'm doing is likely to help. |
|
I guess the thing I don't understand is why it needs to use so much memory. I see it use 6gb every time I click save. Seems just huge for a go app. |
@mrjrieke: We agree, and we'd love to help investigate. Please follow the instructions in the troubleshooting guide and file a new issue, as @heschi requested. Comments without concrete information are not valuable in resolving the problem. |
+1
|
+1 |
$ gopls version |
golang.org/x/tools/gopls v0.9.4 |
it seems every vscode project open will run a gopls process, with each gopls process 2G memory usage, I have to put all the project in one folder |
Please answer these questions before submitting your issue. Thanks!
What did you do?
Our code is in a fairly large monorepo containing about 26K files, including vendored packages.
I use VSCode, with gopls enabled, and launched from the root of our monorepo, so the workspace includes the whole repo.
What did you expect to see?
gopls using 1-2GB of memory. That's a wild guess that I can't really validate, but 8-10 seems excessive.
What did you see instead?
The gopls process is using 8-10GB of memory. This number goes up and down with editor usage, but it never goes below about 6GB, and it generally hovers around 8GB. This is a 16GB laptop, so there's quite a bit of memory pressure when gopls is running.
Nearly all the code in our monorepo is intended for linux, and this is a mac, so I've experimented with adding this setting:
This does affect the number of errors reported by gopls, but the memory consumption is approximately unchanged.
I also tried building the latest master of gopls using the patch mentioned in this bug: #37223. This didn't help either. I'm attaching an SVG heap profile from that version.
pprof.zip
Build info
Go info
The text was updated successfully, but these errors were encountered: