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: not working on a monorepo #37087
Comments
Thank you @stamblerre, here is the (sanitized) log. Not sure if the numbers here are enough information. I need to see how I can reproduce the errors in VSCode. However, what I've seen is that the CPU Load was constantly 50-60%, fans spinning until I've shut VSCode down. Since I've just re-installed my computer and haven't recreated all settings yet I'm running more or less with default install settings.
|
some more stats in case the repo size is an issue:
|
Number of executables built from this repo:
|
It was reproducible this morning. Now I can't repro it. I'll keep an eye on this to see whether I can find a reliable way of triggering this behavior. |
I think have a way of reproducing this:
# build generators
CGO_ENABLED=0 go build -trimpath -mod=vendor -ldflags '-s -w -X github.com/northvolt/our-repo/lib/mapper.version=v1.0.20200203084248-19-ge9962bf9-master' -o build/ ./gen/...
# delete generated code
find driver -name '*_gen.go' -delete
# generate some code
go generate -mod=vendor ./...
Generated /Users/frank/src/github.com/northvolt/our-repo/driver/battery/driver_init_gen.go
Generated /Users/frank/src/github.com/northvolt/our-repo/driver/cajo_printer/driver_init_gen.go
Generated /Users/frank/src/github.com/northvolt/our-repo/driver/cis_presser/driver_init_gen.go
...
Lots of generated code
...
# run tests
CGO_ENABLED=0 go test -trimpath -mod=vendor -ldflags '-s -w -X github.com/northvolt/our-repo/lib/mapper.version=v1.0.20200203084248-19-ge9962bf9-master' -tags=version ./...
# build for all platforms
CGO_ENABLED=0 go build -trimpath -mod=vendor -ldflags '-s -w -X github.com/northvolt/our-repo/lib/mapper.version=v1.0.20200203084248-19-ge9962bf9-master' -o build/darwin_amd64 ./cmd/...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -mod=vendor -ldflags '-s -w -X github.com/northvolt/our-repo/lib/mapper.version=v1.0.20200203084248-19-ge9962bf9-master' -o build/linux_amd64 ./cmd/...
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -trimpath -mod=vendor -ldflags '-s -w -X github.com/northvolt/our-repo/lib/mapper.version=v1.0.20200203084248-19-ge9962bf9-master' -o build/linux_arm ./cmd/... |
@magiconair I also work on a mono repo and have had high cpu utilisation by gopls in VS Code. I have found that turning off deep completion (on by default) seems to help. The following is the snippet, to be added to settings.json. YMMV. Informal use of process explorer in VS Code to see the effects on CPU seems to casually indicate that cpu spikes are way less prolonged
It also worked for a colleague. Maybe you could give this a try and see if it helps? |
Will do. It is much better with 0.4.0 but a colleague had high cpu load again lately. We will try it. |
I am running gopls 0.4.0. If it does indeed work, then it may even make sense to recommend it as a default setting |
@stamblerre I have had a colleague who reported improvement from the high cpu utilisation when working on the same monorepo as I do. Would it make sense to disable |
We would need more evidence before we make a change like that, but we can definitely suggest disabling deep completions as a temporary work-around. I just filed #39113 as a reminder to investigate deep completions further. |
Sure. I think that will be a good course of action |
We no longer treat vendored packages as workspace packages, so I hope that will resolve the high CPU utilization issue when running |
Reported on Twitter: https://twitter.com/magiconair/status/1225358273576083456?s=20.
This is probably caused by the fact that the initial workspace load is running on the entire monorepo (if the directory being opened is the monorepo root). The output of
gopls -rpc.trace -v check path/to/file.go
would be helpful here, as well as the time it takes.The text was updated successfully, but these errors were encountered: