This may be related. I have always had a significant delay when building Go programs on Windows. It mostly happens the first time I build, if I have not built recently. A normal build of a simple program is about 3 seconds of wall clock time, whereas it can take over 20 seconds when it is being slow. Using the Windows tool Process Monitor, I was able to determine that my problem is that a huge number of go standard library files are being read, in their entirety on every build. I thought there was package caching of some sort to avoid this, but apparently not. So about 2,000 standard library files are being read in to build a tiny program. When it is being 'slow' these take around 10-40 milliseconds each. Once things are warmed up, they typically take 0.01 to 0.03 milliseconds each. That seems to account for much of the initial slow build. I am assuming the difference is whether the files are cached in memory by Windows?
I am currently running go 1.19, but have had the same issue for years. Using Windows 10, with anti-virus shut off for the source and build directories. By the way, the Process Monitor tool from Microsoft can be useful in situations like these, as it can give a good indication of how long every operation is taking. On Wednesday, December 14, 2022 at 12:57:40 PM UTC-5 Declan Finn wrote: > Hi, > > Platform: Windows 10 > Go Version: 1.19.4 > > Compile and run of the most basic helloworld program is extremely slow on > my windows machine, taking roughly 30 seconds every time. > Whereas the exact same program, using the same go version, compiles and > runs in under 1 second on my Ubuntu machine. > Why is it so slow on windows? > I asked a collogue to do the same test on his windows machine and he sees > the same slowness. > Any help would be greatly appreciated. > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/43a09191-94e8-4722-a2ea-c072ccb8654en%40googlegroups.com.