Skip to content
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 env' takes 5+ seconds on my Mac #50982

Open
rsc opened this issue Feb 2, 2022 · 10 comments
Open

cmd/go: 'go env' takes 5+ seconds on my Mac #50982

rsc opened this issue Feb 2, 2022 · 10 comments
Labels
NeedsInvestigation

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Feb 2, 2022

I don't know why, but 'go env' regularly takes 5+ seconds on my MacBook Pro, and it's really annoying.
A second 'go env' shortly thereafter is quick.
I suspect the time is going into invoking clang to determine which flags are valid.
I wonder if we are doing that wrong, or if we can avoid it more often?
I also wonder whether this is due to some kind of antivirus/execution "safety" thing on my Mac that forgets that clang is OK.
But I don't know for sure it's clang at all.

Is anyone else seeing this?

@rsc rsc added the NeedsInvestigation label Feb 2, 2022
@matloob
Copy link
Contributor

@matloob matloob commented Feb 2, 2022

I'm seeing this too.

@jfesler
Copy link

@jfesler jfesler commented Feb 2, 2022

Observed ~2 seconds initial delay on Mac mini (M1, 2020), and no perceivable delay on followup runs.

@beoran
Copy link

@beoran beoran commented Feb 3, 2022

I just tried it on the work Mac and I also see this.

@robpike
Copy link
Contributor

@robpike robpike commented Feb 3, 2022

I just tested and got 7.5 seconds!

@juev
Copy link

@juev juev commented Feb 4, 2022

I just tested several times and got:

> time go env
...
go env  0.05s user 0.05s system 74% cpu 0.126 total

@night-codes
Copy link

@night-codes night-codes commented Feb 4, 2022

macOS 12.0.1 / MacBook Pro M1 / go 1.18beta1

go env 0.04s user 0.19s system 82% cpu 0.278 total

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 8, 2022

It could also be a check on go itself and not clang, perhaps by macos gatekeeper

@hyangah
Copy link
Contributor

@hyangah hyangah commented Feb 9, 2022

Probably not go itself.
I ran go env GOOS or go env GOARCH or go env GOPROXY before trying go env. The answer was immediate.
Then, I ran go env. That took good 5sec.

@vatine
Copy link

@vatine vatine commented Feb 10, 2022

Just tried on my Mac (more data points, probably not hurtful):

% time go env
...
go env  0.08s user 0.20s system 49% cpu 0.570 total
% go version
go version go1.17.5 darwin/amd64

This was without pre-warming Go.

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 14, 2022

Change https://go.dev/cl/392454 mentions this issue: cmd/go: cache compiler flag info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests