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: high cpu when call go mod tidy #70608

Closed
WAY29 opened this issue Nov 28, 2024 · 6 comments
Closed

x/tools/gopls: high cpu when call go mod tidy #70608

WAY29 opened this issue Nov 28, 2024 · 6 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

@WAY29
Copy link

WAY29 commented Nov 28, 2024

Go version

go version go1.22.8 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=on
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\coding\golang\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\user\coding\golang
set GOPRIVATE=
set GOPROXY=https://goproxy.cn
set GOROOT=C:\Users\user\.version-fox\cache\golang\current
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\user\.version-fox\cache\golang\current\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.8
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\user\coding\golang\src\yaklang\go.mod
set GOWORK=C:\Users\user\coding\golang\src\yaklang\go.work
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 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\user\AppData\Local\Temp\go-build78613495=/tmp/go-build -gno-record-gcc-switches

What did you do?

When I plan to write code normally and use some libraries from the current file, gopls will automatically import the library for me, which will cause the CPU to soar, causing the entire gopls to be temporarily paralyzed (highlighting, completion, prompts)

What did you see happen?

Sudden CPU surge
go mod tidy -modfile=C:\Users\lang\AppData\Local\Temp\gopls-tempmod246022334\go.mod
image

What did you expect to see?

gopls running normally

@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 Nov 28, 2024
@gopherbot gopherbot added this to the Unreleased milestone Nov 28, 2024
@WAY29
Copy link
Author

WAY29 commented Nov 28, 2024

xtra information:
a new computer purchased a day ago
CPU: AMD Ryzen Al 9 HX 370

@WAY29
Copy link
Author

WAY29 commented Nov 28, 2024

I found that go list also cause the CPU to soar..

@findleyr
Copy link
Member

findleyr commented Dec 5, 2024

Thank you. This is almost certainly related to go list: when you add an import we run go list to list package information.

Does this occur for even a small module? If so, then it may indicate some real bug in go list (for example, mismatching paths that cause spurious cache misses).

@WAY29
Copy link
Author

WAY29 commented Dec 6, 2024

Thank you. This is almost certainly related to go list: when you add an import we run go list to list package information.

Does this occur for even a small module? If so, then it may indicate some real bug in go list (for example, mismatching paths that cause spurious cache misses).

Without further testing, I have moved to WSL to work on it, and while there is no evidence, I suspect Windows Defender is involved

@findleyr
Copy link
Member

Thanks, that sounds likely if it works well in WSL. Please comment if I am misunderstanding.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2024
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

4 participants