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/cmd/gopls: fails on large projects #33221

Closed
banks opened this issue Jul 22, 2019 · 5 comments
Closed

x/tools/cmd/gopls: fails on large projects #33221

banks opened this issue Jul 22, 2019 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@banks
Copy link

banks commented Jul 22, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 darwin/amd64
$ gopls version
version v0.1.3-cmd.gopls, built in $GOPATH mode

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/banks/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/banks/src/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/banks/src/hashicorp/consul/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8t/n45q26t16fvg2z1hwp1_g2240000gn/T/go-build075442172=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Checkout https://github.com/hashicorp/consul master, outside of $GOPATH
  2. Attempt to use gopls (via VsCode extension)

Relevant VSCode config:

"go.useLanguageServer": true,
      "[go]": {
            "editor.snippetSuggestions": "none",
            "editor.formatOnSave": true,
            "editor.codeActionsOnSave": {
                  "source.organizeImports": true
            },
            "editor.codeActionsOnSaveTimeout": 2000
      },
      "gopls": {
            "usePlaceholders": true // add parameter placeholders when completing a function
      },

I also happen to have GO111MODULE=on in ENV currently as I work with a few repos still in GOPATH but this one is NOT in my GOPATH so I assume this makes no difference as Consul has a go.mod file.

What did you expect to see?

Working Auto-completion, auto-imports, formatting, vet etc.

What did you see instead?

All the above work for a short period (anywhere from 1 minute to 20 mins) or so after restarting the lang server (by reinstalling it or kill -9 the gopls PIDs).

After that the gopls output fills up with lines like this (hundreds of lines, distributed over some/all the files I have open in tabs)

[Error - 13:38:46] unable to check package: context canceled
	file = file:///Users/banks/src/hashicorp/consul/agent/proxycfg/state.go

Shortly after I start seeing those mixed with lots of lines like:

work queue is full

At this point none of the features work until I kill gopls again. Code Helper processes consumes some CPU (but not lots) when in this "hung" state but never seems to resolve even after hours of leaving computer idle. I'm not sure if this is only gopls. After posting I realised that when gopls is working it shows up as gopls in Activity Monitor so I my assumption that Code Helper CPU usage was representing gopls is clearly off. In that case gopls seems to be using virtually no CPU at all in its "hung" state.

This project is pretty large and has a lot of large dependencies (thanks to cloud provider SDKs...) but when it's working gopls is very fast and doesn't seem to use a lot of CPU which makes it seem more "hung" than just working hard on lots of deps.

History and Reproduction

This sounds a lot like the previous issue #31712 but in this case is reproducible for me on an OSS repo.

I've been using VSCode and gopls with current configuration for several months on this repository mostly successfully (several times it has broken and I've had to fiddle with config or something to get it to work but it was previously working). This has been failing in this way reproducibly for me for roughly 3-4 weeks (sorry can't be more precise as I've worked around it assuming it to be temporary for a while). I've tried lots of reconfiguring, upgrading etc. to no avail.

For other smaller libraries, my current configuration doesn't seem to have the same issue. So I assume it's related to the size of the project or some specific issue in one of the deps but have been unable to track down what that might be so far.

I hope this issue is useful as a reproducible case of something others have apparently seen intermittently too but couldn't give a good repro for.

@gopherbot gopherbot added this to the Unreleased milestone Jul 22, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 22, 2019
@stamblerre
Copy link
Contributor

Thank you for the detailed report!

I think this error was the result of a fairly recent change - are you using gopls at master? If so, I would recommend sticking to the latest tagged version (go get golang.org/x/tools/gopls@latest), since that will be the version that we have determined to be the most solid.

@ianthehat
Copy link

This was probably fixed in https://go-review.googlesource.com/c/tools/+/186958, similar (but much faster) symptoms were reported in slack and this was the cl I put up to fix them, it fixed the issue for the reporter, and is now sumitted. If you could update to latest (any cl after 8bb11ff) and report back that would be helpful, thanks!

@banks
Copy link
Author

banks commented Jul 23, 2019

@stamblerre Thanks! I think the version I had when reporting here was the one installed automatically by vscode-go. I will stick to latest in future if manually updating. If the version vscode-go installed was ahead of stable, would it make sense to open an issue there? It might be they intentionally target master in an attempt to get bug fixes quicker while the tool is still evolving?

@ianthehat thanks! I've installed master and restarted gopls. So far so good although it's only been a few minutes and I did manage a least a few spells that long yesterday before it was stuck. I'll set a reminder to come back here in a few days to close if there are no further issues!

For reference I'm now on:

$ gopls version
golang.org/x/tools/gopls v0.1.3
    golang.org/x/tools/gopls@v0.0.0-20190723021737-8bb11ff117ca h1:TTXBwr3y5wYTRBYaVOERP4CqwVIM+x/Sn6gdOGwQxDQ=

@stamblerre
Copy link
Contributor

It is possible that VSCode installed from master rather than latest, so if you'd be willing to open an issue there - that'd be great.

Thanks for reporting!

@banks
Copy link
Author

banks commented Jul 25, 2019

After several days, gopls is still working in my editor without manual restarts which is something I've not seen for weeks so I'll close this and assume my issue was fixed by the CL you mentioned @ianthehat thanks!

@stamblerre it does appear that vscode-go does install from master. This value is effectively passed as the argument to go get -u: https://github.com/microsoft/vscode-go/blob/81bc2fa8fc5940e70059201ddfc00af8e7f20e4f/src/goInstallTools.ts#L43

In my case updating to master actually solved the problem! I can see that latest might be a better default choice for vscode-go so I'm happy to create an issue but I suspect the maintainers there would be more interested to hear from you as the authors about the pros/cons of master vs latest for their users. I'll open one and CC you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

4 participants