-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: cache results of exec.LookPath #36768
Comments
go run (timing) It may be of interest to the Golang developers to check the timing of other available downloads. go1.13.6.linux-386.tar.gz
Stripping the files from go1.13.6.linux-386.tar.gz the time is slightly different. GNU 1.7 Plan 9 from User Space |
You didn't fill out the issue template. What is the output of Also, what is the output of |
Ok I've updated my post |
Thanks. Unfortunately I still don't see why it is so slow. What is the output of Since this is Windows, the problem may be due to a virus checker. |
Here's the output:
|
Thanks. I was wondering if it were using external linking, but it's not. I have no explanation other than possibly a virus checker. Sorry. |
The From your update it looks like I installed Golang only once on Windows 10 (64-bit). I downloaded a go1.xx.x.windows-amd64.zip file, extracted it, opened an elevated command prompt and moved it to Next I disabled via the context menu indexing for Does locating |
I moved |
I received a reply to an e-mail I sent to Redmond. Doesn't look like it's specific to AV/Defender. The way you rule out (or in) Defender is to temporarily disable it, do the compile, and then compare on vs off times. Looks like they've done that, though. |
The root of the Go tree cannot be included as a value in the Go path. |
I'm not using Windows, my assumption if did you have made any Windows performance tuning e.g. disable timestamp or etc? |
No. I am able to reproduce this behaviour on another PC that is also windows 10 with i7. |
@Zyxon123 asked me to provide the time measurements on Plan 9 for reference.
|
This is sometimes caused by a broken installation. In this Go1.13 install the first you did on your machine? Or did you update Go from an older version you had? Also, when you write:
do you mean reinstalling over the existing version? If yes, can you instead completely nuke every trace of Go from your machine, and try to follow the installation steps again, from scratch? |
Go 1.13.6 is the first version I did on my machine.
I have just uninstalled Go again by deleting
|
@Zyxon123 thanks for trying. If your installation is not broken and you're absolutely sure your antivirus is not disturbing the compilation process, I don't have any other idea to fix this. These kind of slow-compilation-on-windows issues are most commonly caused by a broken installation or by a nosy antivirus. It's clear that there is something wrong with your machines and/or with the way you're installing Go, since many many people are able to compile a Go hello world in < 1s on Windows; but I don't know what that may be. |
Could someone other than the OP add 9pm's time.exe output go1.10.windows-386.zip
|
@apparluk Windows 10 64-bit time output for reference
|
Mind to share the model and brand of your PC, how much free memory does it has? |
The program in which the command Here's a result from Windows 10 (run in 9term.exe). go1.13.7.windows-amd64.zip
I didn't have the opportunity to obtain the specs on the hardware, There was an earlier ticket regarding CRLF, and IIRC, PowerShell (by default) generates UTF-16 content, when running a go executable to output a string, and that is then redirected to a file. |
Measurement on macOS for reference. go1.13.7.darwin-amd64.tar.gz
|
@Zyxon123, does it still run slowly if you try it several times in a rapid succession? For me (with both workspace and Go installation whitelisted in Defender), it drops from
to
And that's on a M.2 drive with 3Gb/s read speed. |
I'm experiencing slow successive builds too. Tried both 1.14.2 and 1.15rc2. I've made sure my GOCACHE is set and excluded it from Windows Defender, among other directories like the Go installation and project directory. I don't think hardware is an issue because building the project within my WSL distro is quick as expected. Hell - it's quicker iteration for me to cross-compile to Windows from the WSL distro! 😅 This gave me the idea to try both binaries from the same environment:
For completeness the file contents are:
Both installations were installed similarly - just unzipping the folder and adding Strangely it's not just
Something is definitely wrong but I can't find what. |
Could the difference in build time be explained by the file system bridge that WSL uses? |
Are you saying that since I'm accessing One interesting thing I've noticed is when building with
I think I've narrowed it down to this code range just by playing around with build flags to cause fatal errors that failed quickly. https://github.com/golang/go/blob/go1.14.2/src/cmd/go/internal/work/exec.go#L98-L190 I've got no clue what any of this code does, but I hope I'll find it within myself to keep going and build Go from source with debug print statements to narrow down the slowness further, but I'm considering just working off the MacBook at this point lol |
That's my suggestion. I don't have a WSL host to verify, sorry. |
Follow up on CL 511458, see https://go-review.googlesource.com/c/go/+/511458/2..4/src/cmd/go/main.go#b270 . For #36768. Change-Id: Icc2a4dbb1219b1d69dd10a900478957b0e975847 Change-Id: Icc2a4dbb1219b1d69dd10a900478957b0e975847 GitHub-Last-Rev: bac7e66 GitHub-Pull-Request: #61517 Reviewed-on: https://go-review.googlesource.com/c/go/+/512155 Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
This CL package exec.LookPath to internal/cfg.LookPath and adds cache. BenchmarkLookPath-4 26475454 47.84 ns/op 0 B/op 0 allocs/op Fixes golang#36768 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 GitHub-Last-Rev: 04cb24b GitHub-Pull-Request: golang#61464
This CL package exec.LookPath to internal/cfg.LookPath and adds cache. BenchmarkLookPath-4 24149096 50.48 ns/op 0 B/op 0 allocs/op Fixes golang#36768 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 GitHub-Last-Rev: 04cb24b GitHub-Pull-Request: golang#61464
This CL package exec.LookPath to internal/cfg.LookPath and adds cache. BenchmarkLookPath-4 24149096 50.48 ns/op 0 B/op 0 allocs/op Fixes golang#36768 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 GitHub-Last-Rev: 04cb24b GitHub-Pull-Request: golang#61464
This CL package exec.LookPath to internal/cfg.LookPath and adds cache. BenchmarkLookPath-4 24149096 50.48 ns/op 0 B/op 0 allocs/op Fixes golang#36768 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 GitHub-Last-Rev: 04cb24b GitHub-Pull-Request: golang#61464
I'm reverting CL 512155, which mentions this issue; see https://go.dev/cl/527337 for more information. As far as I can tell, that reversion does not affect this issue directly. Please let us know if that is not the case. Thanks. |
I am the author of CL 512155, and I remember that without this CL, on Windows, exec.LookPath would be called once regardless. This means that on Windows, this issue has not been resolved because the actual cached result is not being used, which is approximately equivalent to no cache. |
Now discovering this thread - kudos to @omaskery and @jayconrod for the investigation above :) @qmuntal I think your suggestion in #36768 (comment) sounds reasonable - given that this issue is now solved, perhaps raise a new issue so that it doesn't get lost. You could also raise a CL at the same time, although it's easier for a CL to get lost when there's no issue to track it with. |
Change https://go.dev/cl/528038 mentions this issue: |
This reapplies CL 512155, which was previously reverted in CL 527337. The race that prompted the revert should be fixed by CL 527820, which will be submitted before this one. For #36768. Updates #62596. Change-Id: I3c3cd92470254072901b6ef91c0ac52c8071e0a2 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/528038 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
CL 528038 after ,Is there any reason not to close this issue? |
Agreed, this is now done. |
Change https://go.dev/cl/575255 mentions this issue: |
Change https://go.dev/cl/581695 mentions this issue: |
CL 512155 fixed #36768, but introduced #62596. CL 527820 fixed #62596, but meant that the code failed to look up file extensions on Windows for a relative path. This CL fixes that problem by recording whether it has already looked up file extensions. This does mean that if Path is set manually then we do not update it with file extensions, as doing that would be racy. Fixes #66586 Change-Id: I9a0305d1e466c5e07bfbe442566ea12f5255a96e GitHub-Last-Rev: dc3169f GitHub-Pull-Request: #67035 Reviewed-on: https://go-review.googlesource.com/c/go/+/581695 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
…n if not already done CL 512155 fixed golang#36768, but introduced golang#62596. CL 527820 fixed golang#62596, but meant that the code failed to look up file extensions on Windows for a relative path. This CL fixes that problem by recording whether it has already looked up file extensions. This does mean that if Path is set manually then we do not update it with file extensions, as doing that would be racy. Fixes golang#66598 Change-Id: Id6199945ecca7bbe19d531070eea66b206b0564b
Change https://go.dev/cl/591397 mentions this issue: |
Change https://go.dev/cl/594495 mentions this issue: |
…n if not already done CL 512155 fixed #36768, but introduced #62596. CL 527820 fixed #62596, but meant that the code failed to look up file extensions on Windows for a relative path. This CL fixes that problem by recording whether it has already looked up file extensions. This does mean that if Path is set manually then we do not update it with file extensions, as doing that would be racy. For #66586 Fixes #66598 Change-Id: I9a0305d1e466c5e07bfbe442566ea12f5255a96e GitHub-Last-Rev: dc3169f GitHub-Pull-Request: #67035 Reviewed-on: https://go-review.googlesource.com/c/go/+/581695 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> (cherry picked from commit 5532427) Reviewed-on: https://go-review.googlesource.com/c/go/+/594495 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Hi,
I followed the steps here after I installed Go. However, running
go run hello.go
takes around 10 - 20 seconds for it to output “hello, world”. Same thing withgo build
. I’ve also tried reinstalling and excluding my Go folder and Go temp folder from windows defender (the only antivirus I use). I've even disabled real time protection. How do I fix this? Any help is appreciated.Thanks!
What did you expect to see?
I expect a hello world program to be compiled within seconds, other users are able to do so.
What did you see instead?
Takes 10-20 seconds to compile instead.
go run -x output
The text was updated successfully, but these errors were encountered: