Recently, my go build has been very slow.
The trace below suggests that while compilation itself (exec.Builder.Do) is pretty fast taking 7s,
loading modules (load.PackagesAndErrors) is excruciating slow, taking 31s!
Hi @fumin, the trace link does not seem to open for me. I get an error saying the trace cannot be found.
Without a closer look, it could be that your build downloads a lot of modules, or large modules, possibly over a slow connection. Did you trace network activity during the build?
Without a closer look, it could be that your build downloads a lot of modules, or large modules, possibly over a slow connection
I can build my program without network, so connection issues are ruled out.
I am aware that the disk on my laptop is pretty slow, so this might be an issue.
However, I wonder how can I prove this? I presume loading modules does require a lot disk lookup operations?
What version are you on? I noticed with my current version builds are noticeably slower than on 1.19. Here’s my version:
go version go1.20.4 windows/amd64
If you’re on 1.20, you could try downgrading to 1.19. I assumed it was something messed up with my local install, but if you are experiencing the same thing there might be a chance it’s related to 1.20? Not sure.
It’s hard to say because I didn’t do any benchmarks previously but it certainly feels quite a bit slower. I have a pretty fast development machine and on some of my projects I cortesi/modd to watch and continuously build my API (similar to using something like preact watch but for my back-end) so I am especially sensitive to slowdowns in build time. It’d be interesting to see if vendoring my dependencies fixed the problem (since @fumin noted that most of the time is spent on modfetch.download).
For me, it’s a minor annoyance and as I mentioned I just assumed it was something in my environment so I didn’t spend too much time troubleshooting it. And if it’s a regression in version 1.20 it will almost certainly be found and fixed at some point.