Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/gopls: excessive invocations of "go mod tidy" #38816
Running gopls from golang/tools@542909f (latest as of writing).
Go 1.14.2; Ubuntu 20.04, amd64.
What did you do?
While working on a Go project whose working directory happened to contain many non-go files (millions of xml files), I discovered that my machine was becoming bogged down by something. In the end I discovered tens of "go mod tidy" processes all competing with each other to stat all of these files. (That cmd/go bug is covered by #38791).
What did you expect to see?
Normal operation of my computer (not progressively slowing down with ever more procesess).
What did you see instead?
CPU spiral of doom, with >30 go mod tidy processes running and the computer becoming progressively more unusable.
This highlighted that
@mvdan and @bcmills discussed that gopls may be able in principle to do better at minimizing
There is another concern here, which is that gopls allowed so many concurrent invocations of go mod tidy which were stuck competing for the same resources. It seems that these should be gated, and some sort of timeout/warning in place if it takes excessively longer than expected.
Consider guarding it with a semaphore to limit to one invocation at a time, and/or signaling the previous
Thanks for following up on this. I agree that we shouldn't be running
@pwaller, if you have a public repro case, that would be helpful, but no worries if not - this sounds simple enough to reproduce.