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: context deadline exceeded with windows 10 wsl2 #49475

Open
wu0407 opened this issue Nov 9, 2021 · 6 comments
Open

x/tools/gopls: context deadline exceeded with windows 10 wsl2 #49475

wu0407 opened this issue Nov 9, 2021 · 6 comments

Comments

@wu0407
Copy link

@wu0407 wu0407 commented Nov 9, 2021

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

$ go version
go version go1.17.3 linux/amd64
gopls: v0.7.3

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 version go1.17.3 linux/amd64
xiaoqing@DESKTOP-NTTMOHE:~$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xiaoqing/.cache/go-build"
GOENV="/home/xiaoqing/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/xiaoqing/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/xiaoqing/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build2970027064=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Open kubernetes code in use vscode with wsl mode.
go extention report "go.mod context deadline exceeded"
I see gopls use many cpu a few time, then low cpu and memory not increase.

What did you expect to see?

no probelm

What did you see instead?

###gopls trace log on local vscode

[Trace - 19:20:32.674 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/11/09 19:20:32 errors loading workspace: context deadline exceeded\n\tsnapshot=0\n\tdirectory=file:///mnt/d/git/kubernetes\n"}


[Error - 7:20:32 PM] 2021/11/09 19:20:32 errors loading workspace: context deadline exceeded
	snapshot=0
	directory=file:///mnt/d/git/kubernetes

[Trace - 19:20:32.675 PM] Sending response 'window/workDoneProgress/create - (5)' in 1ms.
Result: 


[Trace - 19:20:32.675 PM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"begin","title":"Error loading workspace","message":"context deadline exceeded"}}


[Trace - 19:20:32.704 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///mnt/d/git/kubernetes/go.mod","diagnostics":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":24}},"severity":1,"source":"go list","message":"context deadline exceeded"}]}

###full log:
gopls-wsl-context-timeout.txt

@gopherbot gopherbot added this to the Unreleased milestone Nov 9, 2021
@bcmills
Copy link
Member

@bcmills bcmills commented Nov 9, 2021

IIRC the /mnt filesystem on WSL2 is extremely slow. Perhaps gopls just needs to set a longer deadline?

Loading

@wu0407
Copy link
Author

@wu0407 wu0407 commented Nov 10, 2021

IIRC the /mnt filesystem on WSL2 is extremely slow. Perhaps gopls just needs to set a longer deadline?

Yes, I can't find any options with gopls timeout.

Loading

@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 10, 2021

I am afraid timeout longer than 10min is not ideal - according to the trace, the loading failed after more than 10min.

[Trace - 18:40:40.585 PM] Sending response 'window/workDoneProgress/create - (1)' in 5ms.
Result: 


[Trace - 18:40:40.587 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Error - 6:52:08 PM] 2021/11/09 18:52:08 initial workspace load failed: context deadline exceeded

I think for wsl, VS Code recommends Visual Studio Code Remote - WSL extension than starting with the /mnt filesystem. I see loading k8s workspace take ~22secs on my windows running on amd ryzen - still long time but not like more than 10min.

Loading

@hyangah hyangah removed this from the Unreleased milestone Nov 10, 2021
@hyangah hyangah added this to the gopls/unplanned milestone Nov 10, 2021
@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 12, 2021

@wu0407 Can you please check if you have the same issue when you use the WSL extension?

Loading

@wu0407
Copy link
Author

@wu0407 wu0407 commented Nov 15, 2021

same result with wsl extention start wsl and manual start wsl. @hyangah

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Nov 18, 2021

IIRC gopls has to read something like 25K files and load 3-6GB of memory for Kubernetes (depending on if you're using staticcheck). This takes 30-45s on my (rather powerful) linux desktop. I am not at all surprised to hear that gopls is unusable at such scale on WSL2.

We are considering a project to allow gopls to avoid loading the entire workspace for projects like Kubernetes, hopefully for early 2022. In the meantime, gopls will not work well for this use case, sorry.

I'm going to leave this in the backlog, so that we may find it while working on performance (and hopefully verify that it is improved).

Loading

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
5 participants