]> Cypherpunks repositories - gostls13.git/commit
cmd/go: limit total compile -c backend concurrency using a pool
authorMichael Matloob <matloob@golang.org>
Mon, 24 Nov 2025 23:33:30 +0000 (18:33 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 26 Nov 2025 21:48:13 +0000 (13:48 -0800)
commit623ef2813579c9b52ba4a0335722df4d93566b74
treefc5edf04a1ce5107323a37eac774721d149d56ba
parent3c6bf6fbf38062b24a7cf0390f1e617d733851b3
cmd/go: limit total compile -c backend concurrency using a pool

Previously we limited the value we passed in to compile -c (which set
the number of SSA compile goroutines that run at one time) to 4. This CL
allows the -c value to go up to GOMAXPROCS, while limiting the total
number of backend SSA compile goroutines to still be less than the
previous worst case of 4*GOMAXPROCS (actually four times the value of
the -p flag, but the default is GOMAXPROCS). We do that by keeping a
pool of tokens to represent the total number of SSA compile goroutines
(with some buffer to allow us to run out of tokens and not exceed
4*GOMAXPROCS). Each time a compile requests a -c value, we'll hand out
half of the remaining tokens (with the number handed otu capped at
GOMAXPROCS) until we run out of tokens, in wich case we'll set -c to
one.

This leads to a speed up of 3-10% on the 16 core intel perf builder and
5-16% on the 88 core builder on the Sweet go-build benchmark.

Change-Id: Ib1ec843fee57f0fb8d36a507162317276a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/724142
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
src/cmd/go/internal/work/gc.go
src/cmd/go/internal/work/init.go