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: timeout when lookup is used in kubernetes code base #38032

Closed
szuecs opened this issue Mar 23, 2020 · 10 comments
Closed

x/tools/gopls: timeout when lookup is used in kubernetes code base #38032

szuecs opened this issue Mar 23, 2020 · 10 comments
Labels
Milestone

Comments

@szuecs
Copy link

@szuecs szuecs commented Mar 23, 2020

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

$ go version
go version go1.14.1 linux/amd64

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
% go env                                                           master
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/sszuecs/go/bin"
GOCACHE="/home/sszuecs/.cache/go-build"
GOENV="/home/sszuecs/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sszuecs/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/share/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/sszuecs/go/src/k8s.io/kubernetes/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build833352984=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. I open https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go in my Emacs text editor with gopls, which works nicely in small/medium sized projects.
  2. I try to browse the code and lookup struct members or functions (always timeouts)
  3. I increased the timeout to 60s (lsp-response-timeout 60) does not help, but it blocks the editor for 60s.

What did you expect to see?

Lookup happening in some short time.

What did you see instead?

Timeout

@gopherbot gopherbot added this to the Unreleased milestone Mar 23, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 23, 2020

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.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Mar 23, 2020
@muirdm
Copy link

@muirdm muirdm commented Mar 23, 2020

What version of gopls are you using?

I try to browse the code and lookup struct members or functions (always timeouts)

Can you detail what operations you are doing? Are you trying to complete or jump to definition, or something else? It would be good if you give the exact command/keypress and the exact location in the file so we can be sure we are doing the same thing.

@szuecs
Copy link
Author

@szuecs szuecs commented Mar 23, 2020

% gopls version
golang.org/x/tools/gopls v0.3.4
golang.org/x/tools/gopls@v0.3.4 h1:4GC7q/pXQ/tsxHBGVdsMdlB4gCxVC06m/7rIXg1Px4E=

For example try to lookup in line 288 config.NewPodConfigfunction definition with M-.

@muirdm
Copy link

@muirdm muirdm commented Mar 23, 2020

That works fine (instantly) for me. Is there anything in *lsp-log*?

@szuecs
Copy link
Author

@szuecs szuecs commented Mar 23, 2020

Creating watch for /home/sszuecs/go/src/k8s.io/kubernetes/vendor/github.com/google
Creating watch for /home/sszuecs/go/src/k8s.io/kubernetes/vendor/github.com/google/btree
.....----8<---
Creating watch for /home/sszuecs/go/src/k8s.io/kubernetes/vendor/vbom.ml
Creating watch for /home/sszuecs/go/src/k8s.io/kubernetes/vendor/vbom.ml/util
Creating watch for /home/sszuecs/go/src/k8s.io/kubernetes/vendor/vbom.ml/util/sortorder
2020/03/23 19:06:55 Build info
----------
golang.org/x/tools/gopls v0.3.4
    golang.org/x/tools/gopls@v0.3.4 h1:4GC7q/pXQ/tsxHBGVdsMdlB4gCxVC06m/7rIXg1Px4E=
    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-20200316194252-fafb6e2e8a4a h1:hKrQy/q8/Xivoqgw6nGiz1jqpn1WGBLDcWLZwW0983E=
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.14.1 linux/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/sszuecs/go/bin"
GOCACHE="/home/sszuecs/.cache/go-build"
GOENV="/home/sszuecs/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sszuecs/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/share/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/sszuecs/go/src/k8s.io/kubernetes/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build799968170=/tmp/go-build -gno-record-gcc-switches"
@szuecs
Copy link
Author

@szuecs szuecs commented Mar 23, 2020

in * messages* I see:

lsp-request: Timeout while waiting for response. Method: textDocument/definition.
@muirdm
Copy link

@muirdm muirdm commented Mar 23, 2020

Is there smoething at the bottom of *lsp-log* after a timeout? Is gopls using a lot of CPU?

Can you try (setq lsp-enable-file-watchers nil) and then (lsp-restart-workspace)?

@szuecs
Copy link
Author

@szuecs szuecs commented Mar 23, 2020

After waiting some time without doing anything it shows the docs for the function and I can lookup very fast.
Indeed gopls used a lot of CPU.

(setq lsp-enable-file-watchers nil) speedups the process for the first lookup, which times out in my case. I see go list and gopls with high CPU for some seconds, longer than my 3s timeout. After that it works fast for things of the target module, that I tried to lookup.

@muirdm
Copy link

@muirdm muirdm commented Mar 23, 2020

There is an expected delay on startup while gopls parses and type checks everything for the first time.

@szuecs
Copy link
Author

@szuecs szuecs commented Mar 23, 2020

via slack:

do you want to let this issue open or do you want to close it?
I am not sure if I can expect kubernetes code lookup works in 3s if I just start emacs and open the file, browse to the line and try to lookup. wdyt?
19:22
After some seconds everything is super fast
@szuecs szuecs closed this Mar 23, 2020
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
4 participants
You can’t perform that action at this time.