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: becomes slow in vscode after creating then deleting the $gopath/src and the vendor folder #62021

Open
NewUserHa opened this issue Aug 14, 2023 · 4 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@NewUserHa
Copy link

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

$ go version
go version go1.21.0 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\User\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\User\go
set GOPRIVATE=
set GOPROXY=https://goproxy.io,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\User\AppData\Local\Temp\go-build959162870=/tmp/go-build -gno-record-gcc-switches

What did you do?

  1. having a .go and .mod file, and the content doesn't matter. open it with vscode. ( at this time "go to def" and "format" functions work normally)
  2. using go vendor create the vendor folder. ( this requires you to have at least one 3rd party library imported )
  3. also copying the content of the vendor folder to $gopath/src.
  4. delete the 2 folders created by step 2 and step 3.
  5. "go to def" and "format" respond very slowly it takes about minutes to format once.

What did you expect to see?

"go to def" and "format" work normally as always.

What did you see instead?

"go to def" and "format" respond very slowly or becomes unresponsive.

note:

  1. I didn't test which folder actually causes this issue, but I guess both of them can.
  2. the reason for doing step 2 and 3 are for the repl tool yaegi to import 3rd party package to work, but it fails, maybe because of windows according to some comments from its github repo issues that it only tested on linux and not like to support windows.
  3. another trivial issue in step 5 is that there's also a popup at right bottom corner says "saving .go something configuration". this popup also appeared sometimes before, but the configuration is empty if you click the goto setting url
@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 Aug 14, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 14, 2023
@NewUserHa NewUserHa changed the title x/tools/gopls: becomes slow after creating then deleting the $gopath/src vendor folder in vscode x/tools/gopls: becomes slow in vscode after creating then deleting the $gopath/src and the vendor folder Aug 14, 2023
@findleyr
Copy link
Contributor

@NewUserHa does this slowness go away after a restart?

(I have a suspicion of what this is)

@NewUserHa
Copy link
Author

yes, it goes away after restarting vscode.

I guess the reason is that gopls still scans the deleted folders and doesn't timeout. I can't PR since I can't find the position of the gopls scan function.

@findleyr
Copy link
Contributor

@NewUserHa I think the problem is actually that gopls tries to reload all the invalidated packages, rather than starting over from scratch.

It has been on my list to add a heuristic like "if too much has changed, just start over".

@NewUserHa
Copy link
Author

ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants