-
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 run and go tool are slower than directly executing cached binary #71733
Comments
is this a corporate mac with endpoint security software running on it? |
Nope, no entrerprise-y shenanigans. Apple's Gatekeeper is enabled, of course, but it should affect all the solutions equally. |
CC @matloob, @samthanawalla. |
I'm seeing this as well. |
The caching support for I'm sure there's a lot we can do to make the go command faster, and I would love to see it become faster, but this level of performance is pretty much what we expect. I would definitely like to hear about use cases that are adversely impacted by this. We would also definitely welcome changes that improve the performance of the go command without impacting its complexity. |
With a fast caching Go could be used to write a wrapper around CLI tools. 5ms is acceptable, but 50ms is already perceptible for interactive invocation, and if it is a wrapper around a often-called tool (e.g. a wrapper for a compiler) then these milliseconds begin to add up quickly. |
My use case is around build tooling: wrapping a utility for integrating Go into Makefiles. I need to run the wrapped utility ~30 times per @dottedmag I've tried to work around this problem by fetching the tool path with |
The trickiest part is cache revalidation, as usual. I'm striving for a replacement for "go run" — a tool that can be used without thinking about stale caches. With I understand that in your use-case you may be reasonably sure that the source code of your wrapper does not change under you as you're building things. In mine it's a source of frustration when I or somebody else on the team change branches and then 30 minutes later figure out the tool was stale. |
Thanks for your responses. I think for these use cases, we'd be happy to accept performance increase CLs that don't increase the complexity of the go command. @iwahbe I'm curious why doing a |
I use I don't want a global install, and running ❯ go build -o bin/v0.1.0/helpmakego github.com/iwahbe/helpmakego
no required module provides package github.com/iwahbe/helpmakego; to add it:
go get github.com/iwahbe/helpmakego |
@iwahbe For the |
Running Maybe the error message for
If that is true, this I'm not sure why |
Sorry, I should have clarified: I was comparing using |
I'm going to close this issue for now. If you have suggestions for specific work that can be done on the go command that can improve performance without adding complexity, please file an issue and we can discuss the specific proposals. |
Go version
go version go1.24.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I have tried running
go run
andgo tool
with trivial programs, expecting them to exit nearly instantly.Instead I'm seeing run times of ~50ms on Mac M1 Max with warm caches.
Here's a repository with a reproducer: https://github.com/dottedmag/gr-go-run
Run
go test -bench=.
.The basis for a comparison is a tool I wrote some time ago, before link-caching has been merged to Go. It uses a cache key computation algorithm that is fairly close to the original one (borrowing some code directly from Go), and still outperfroms
go run
5ms to 50ms.What did you see happen?
What did you expect to see?
go run
orgo tool
are expected to be at least on par with an external tool that does not hook into the compilation process, now that the linker outputs are cached.The text was updated successfully, but these errors were encountered: