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

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

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

rsc opened this issue Feb 2, 2022 · 10 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rsc
Copy link
Contributor

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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 2, 2022
@matloob
Copy link
Contributor

matloob commented Feb 2, 2022

I'm seeing this too.

@jfesler
Copy link

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 commented Feb 3, 2022

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

@robpike
Copy link
Contributor

robpike commented Feb 3, 2022

I just tested and got 7.5 seconds!

@juev
Copy link

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 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
Member

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

@hyangah
Copy link
Contributor

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 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

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

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
@golang golang locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests