-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
On Linux:
$ perflock bash -c 'for i in $(seq 10); do rm -f /tmp/x1 && 9 time go build -o /tmp/x1 cmd/go; done'
1.27u 0.14s 1.10r go build -o /tmp/x1 cmd/go ...
1.23u 0.16s 1.09r go build -o /tmp/x1 cmd/go ...
1.18u 0.17s 1.12r go build -o /tmp/x1 cmd/go ...
1.20u 0.16s 1.11r go build -o /tmp/x1 cmd/go ...
1.22u 0.18s 1.07r go build -o /tmp/x1 cmd/go ...
1.23u 0.13s 1.09r go build -o /tmp/x1 cmd/go ...
1.23u 0.15s 1.08r go build -o /tmp/x1 cmd/go ...
1.25u 0.14s 1.09r go build -o /tmp/x1 cmd/go ...
1.23u 0.14s 1.05r go build -o /tmp/x1 cmd/go ...
1.21u 0.15s 1.08r go build -o /tmp/x1 cmd/go ...
$ perflock bash -c 'for i in $(seq 10); do rm -f /tmp/x2 && 9 time go build -ldflags=-w -o /tmp/x2 cmd/go; done'
0.66u 0.16s 0.63r go build -ldflags=-w -o /tmp/x2 ...
0.72u 0.12s 0.63r go build -ldflags=-w -o /tmp/x2 ...
0.67u 0.13s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.66u 0.17s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.67u 0.13s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.66u 0.16s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.68u 0.14s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.66u 0.13s 0.58r go build -ldflags=-w -o /tmp/x2 ...
0.68u 0.13s 0.57r go build -ldflags=-w -o /tmp/x2 ...
0.70u 0.10s 0.59r go build -ldflags=-w -o /tmp/x2 ...
$
Just plain "go list -json cmd/go", which essentially does the prep for a build, takes about 0.12r, so the upper bound on time spent in link here is about 0.45r without DWARF and 0.93r with DWARF. That is, emitting DWARF doubles the amount of time it takes for the linker to execute. We don't pay this cost for "go test" or "go run", because we turn DWARF off for those already.
The Mac shows a similar ~2X slowdown. I thought maybe #12259 was related but given that Linux clearly is unaffected by that issue, it appears to be a general DWARF problem.
I've put the proposal to turn off DWARF by default (#26074) on hold pending better understanding of where all the time is going (this issue). If we decide that DWARF really is a 2X cost, then we need to go back to #26074 and decide whether that's worth paying on every build when most people make no use of the DWARF info.
/cc @dr2chase @cherrymui @thanm @ianlancetaylor @randall77 @aclements @RLH