-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: go build is very slow on windows without -p=1 parameter #71981
Comments
I also reproduced a similar situation on another PC with similar configuration (go1.23.4, AMD 7745H, Samsung 980 PRO NVMe SSD, Windows 11 24H2), and Windows Defender is turned off on all systems. |
This is the analysis screenshot and source file compiled with the |
do repeated (cached) builds also have the same slowdown? |
Yes, I tested it many times. The slowdown occurs when not using |
Thanks for reporting. I cant' reproduce the 40s slow down, but I do see a 3x slowdown when building without |
Hi @qmuntal, one quick passing thought is maybe cmd/go's internal
https://pkg.go.dev/cmd/internal/robustio Also, I know you've contributed a bunch (including I think you and I interacted on some Window's timer issues), but I don't know how much you've looked at cmd/go, so I'll also just quickly mention In 1.24, there's also the
In any event, consider these drive-by comments that might not be actually useful. 😅 edit: and looking at the problem report more carefully, I see @devhaozi already mentioned some of this. |
Thanks for the tips @thepudds! I'm currently following this lead: most packages consistently take just ~10ms to build when using This might be a reporting issue or some in-memory caches being warmed up, or could be something deeper. |
Change https://go.dev/cl/653715 mentions this issue: |
Interesting finding: each build thread is running several I've submitted CL 653715, which improves the build action so that it doesn't spawn that many commands. On a my Windows machine (that has 12 virtual CPUs), the time to build a hello world program is reduced from over 1 second, with spikes of 2 seconds, to a consistent 0.7 seconds. Also, now almost all individual build actions last around 30ms, which is more similar to the The actiongraph looks much better now (use the I'm not sure if this fixes the issue reported in here, but it's an improvement 😄. |
The tool IDs can be calculated once and reused across multiple threads. This is a small optimization that helps optimize system resources. On a normal Windows machine with 12 virtual CPUs, the time to build a hello world program is reduced from over 1 second, with spikes of 2 seconds, to a consistent 0.7 seconds. Updates #71981. Change-Id: I85f4a19f8ad4230afa32213780c761b7eb22fa29 Reviewed-on: https://go-review.googlesource.com/c/go/+/653715 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Cool! Then I would consider this issue closed. We could backport the fix given it's small size. But this is not a new regression, so I don't know if it makes the cut. @golang/release. |
Go version
go version go1.24.0 windows/amd64
Output of
go env
in your module/workspace:What did you do?
I wrote a very simple hello world program.
Then I compiled it using the
go build -p=1 -debug-actiongraph="compile.json"
andgo build -debug-actiongraph="compile2.json"
commands respectively, and used the actiongraph tool to analyze the results.What did you see happen?
The results are as follows:
Obviously, the normal speed is achieved after using the
-p=1
parameter, while it takes 40s without using it.My PC uses an AMD 6800H processor and a Samsung 980 PRO NVMe SSD. I think it's unlikely that it's a hardware problem that causes such a big difference.
What did you expect to see?
Compilation speed is normal when
-p=1
parameter is not used.The text was updated successfully, but these errors were encountered: