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: slow performance #43259

Closed
zhaytee opened this issue Dec 18, 2020 · 6 comments
Closed

x/tools/gopls: slow performance #43259

zhaytee opened this issue Dec 18, 2020 · 6 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@zhaytee
Copy link

zhaytee commented Dec 18, 2020

What version of Go, VS Code & VS Code Go extension are you using?

go version: go1.14.9 linux/amd64
gopls version: golang.org/x/tools/gopls v0.6.1
vscode version: 1.52.1 (commit ea3859d4ba2f3e577a159bc91e3074c5d85c0523)
vscode-go version: 0.19.1

Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /home/zhaytee/go
GOROOT: /usr/local/go
PATH: /usr/local/go/bin:/home/zhaytee/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/home/zhaytee/.nvm/versions/node/v12.18.4/bin:/home/zhaytee/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zhaytee/go/bin:/home/zhaytee/.local/bin

   gocode: gocode not installed
   gopkgs: gopkgs not installed
   go-outline: go-outline not installed
   go-symbols: go-symbols not installed
   guru: guru not installed
   gorename: gorename not installed
   gotests: gotests not installed
   gomodifytags: gomodifytags not installed
   impl: impl not installed
   fillstruct: fillstruct not installed
   goplay: goplay not installed
   godoctor: godoctor not installed
   dlv: dlv not installed
   gocode-gomod: gocode-gomod not installed
   godef: godef not installed
   goreturns: goreturns not installed
   golint: golint not installed
   gopls: /home/zhaytee/go/bin/gopls installed

go env
Workspace Folder (api): /home/zhaytee/Development/platform/api
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/zhaytee/.cache/go-build"
	GOENV="/home/zhaytee/.config/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/zhaytee/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/usr/local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
	GCCGO="gccgo"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD=""
	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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build361984029=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
    "go.autocompleteUnimportedPackages": true,
    "gopls": {
        "usePlaceholders": false,
        "staticcheck": false
    },
    "go.languageServerExperimentalFeatures": {
        "diagnostics": true
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
    },
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
        "editor.snippetSuggestions": "none",
    }
}

Describe the bug

VSCode is running on macOS, vscode-go is running on linux/amd64 (I'm using the remote-ssh extension).

Apologies if this is a duplicate, but I couldn't find anything quite similar in the issues log.

Performance is very slow when gopls is performing autocomplete. It takes many seconds (between 3 and 5) to pop up the autocomplete dialog, which is just way too long when I'm trying to move fast.

Please see the linked video for a quick demo: https://www.youtube.com/watch?v=H2aCyG7e_hY

Notice the gopls debugging output. I don't see any one response type standing out as being the slowest; all of the relevant ones seem to be really slow: codeAction, foldingRange, documentLink, codeLens, documentSymbol, completion, etc.

Any help to speed this up would be greatly appreciated! Thank you.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 18, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 18, 2020
@stamblerre stamblerre changed the title x/tools/gopls: Slow performance x/tools/gopls: slow performance Dec 18, 2020
@stamblerre
Copy link
Contributor

Can you please share your gopls logs? See https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs for details on how to capture them. Thanks!

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 18, 2020
@zhaytee
Copy link
Author

zhaytee commented Dec 18, 2020

Here's a pretty clean trace from the moment I started typing (same as in the video) until the gopls activity stopped.

gopls-trace.txt

@andig
Copy link
Contributor

andig commented Dec 20, 2020

There are a number of cancelled requests like these:

[Trace - 20:11:36.318 PM] Sending request 'textDocument/completion - (39)'.
Params: {"textDocument":{"uri":"file:///platform/identity/ensure/ensure.go"},"position":{"line":527,"character":23},"context":{"triggerKind":1}}


[Trace - 20:11:36.342 PM] Received notification 'textDocument/publishDiagnostics'.

@stamblerre
Copy link
Contributor

@zhaytee: Above, you mention that your workspace folder is /home/zhaytee/Development/platform/api, but in the logs I see /platform/identity/ensure. Do you have a go.mod file in this workspace? I'm not seeing one in the go env output you shared above.

Also, it looks like you've shared an incomplete log. Can you please include a log that starts from the initialize message at the top? Most of the gopls debugging information is logged early on.

@zhaytee
Copy link
Author

zhaytee commented Dec 23, 2020

Apologies, I haven't had time to update this issue properly. However, I did want to mention that I recently upgraded the version of Go on my dev box from 1.14.9 to 1.15.6, and things seem a LOT faster. I don't know if there's a good reason for that, or if it's just a coincidence.

@stamblerre
Copy link
Contributor

Glad things are working better now. I'll go ahead and close this since the issue's resolved, but feel free to reopen if you run into it again.

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Dec 23, 2020
@golang golang locked and limited conversation to collaborators Dec 23, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants