Skip to content
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: reduce memory usage #36943

Open
stamblerre opened this issue Jan 31, 2020 · 9 comments
Open

x/tools/gopls: reduce memory usage #36943

stamblerre opened this issue Jan 31, 2020 · 9 comments

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Jan 31, 2020

This is a general tracking issue for memory usage in gopls. We need to collect data and set goals for usage for a given project size. We also need to work towards reducing the memory usage when staticcheck is enabled (though that may be a separate issue).

If you have a specific problem with gopls using too much memory on your machine, please create a new issue so that we can investigate it separately.

Please include your VS Code settings and heap profiles with your issue. These can be collected by adding the following settings to your VS Code settings.json:

"go.languageServerFlags": [
    "-rpc.trace",
    "serve",
    "--debug=localhost:6060"
]

and running go tool pprof -http :8080 http://localhost:6060/debug/pprof/heap. For other editors, see details here.

@mnrce

This comment has been minimized.

Copy link

@mnrce mnrce commented Feb 4, 2020

I just upgrade gopls to v0.3.0 today so that I'm able to rename symbols / find reference across package, but the memory usage is very high:
image

Edit: It's a small private project, the only dependency is beego

I'm using Ubuntu 16.04

gopls version:

golang.org/x/tools/gopls v0.3.0
golang.org/x/tools/gopls@v0.3.0 h1:l9KKK1/n6CIbfgaUvHBWAvCfOxcl1N+KSOK79OlPIao=

go version:

go1.13.4 linux/amd64

@patrikeh

This comment has been minimized.

Copy link

@patrikeh patrikeh commented Feb 4, 2020

As the commenter above, I've have had problems with massive memory usage since upgrading to 0.3.0 yesterday, sometimes upward of 12 GB.

Screen Shot 2020-02-04 at 11 29 12 AM

macOS Mojave 10.14.6
go version go1.13 darwin/amd64
golang.org/x/tools/gopls@v0.3.0 h1:l9KKK1/n6CIbfgaUvHBWAvCfOxcl1N+KSOK79OlPIao=

@guiguan

This comment has been minimized.

Copy link

@guiguan guiguan commented Feb 4, 2020

Screen Shot 2020-02-04 at 9 52 18 pm

same here :(

@myitcv

This comment has been minimized.

Copy link
Member

@myitcv myitcv commented Feb 4, 2020

@guiguan there is absolutely no need for language like that. Please, keep the feedback constructive.

FWIW this has already been fixed on master via https://go-review.googlesource.com/c/tools/+/217677

@stamblerre

This comment has been minimized.

Copy link
Contributor Author

@stamblerre stamblerre commented Feb 4, 2020

I'm sorry that you all encountered this bug - we had a memory leak that was a bit tricky to reproduce, but as @myitcv said, we believe that we've fixed it. You can try it out by downloading the pre-release for the next version of gopls (GO111MODULE=on go get golang.org/x/tools/gopls@v0.3.1-pre1). Please report here if you still see the excessive memory usage with that version.

@vincepri

This comment has been minimized.

Copy link

@vincepri vincepri commented Feb 6, 2020

@stamblerre On the latest master, gopls is using more than 30GB when developing with some kubernetes sub-projects

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Feb 6, 2020

@vincepri per the bold section in the original issue, please file a new issue with repro instructions, even if they're just "check this repository out and open it."

@trajber

This comment has been minimized.

Copy link

@trajber trajber commented Feb 6, 2020

@stamblerre @heschik

I'm using the latest master and the memory usage is relatively large for a small/medium project. (~1.5GB)
Unfortunately I cannot share the project, but I can send you the pprof heap file for gopls, if it helps 🤷‍♂

Build info

golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.3.1 h1:yNTWrf4gc4Or0UecjOas5pzOa3BL0WDDyKDV4Wz5VaM=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20200206141423-2529d2857af7 h1:BtAc3ytYUhbzaL+TpDGZSBVecmz6ra8/VYiIwtasXXc=
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Here you can find the pprof heap file

Let me know if you need any more info from my side that can be useful for you.

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik commented Feb 6, 2020

@trajber Unfortunately I don't see any signs of a bug in your profile. That doesn't mean there isn't one, but 1.5GiB is not completely out of line for a project with a lot of dependencies, and without access to the source it's very difficult to judge. Sorry, but I don't think there's going to be much we can do in the short term. Hopefully you will benefit from general optimizations we make in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.