Commit a1aefc2fb3 for golang

commit a1aefc2fb338060a98840a2da50c14c670a65d0c
Author: Michael Matloob <matloob@golang.org>
Date:   Mon Nov 30 15:00:04 2026 -0500

    cmd/dist: limit concurrent build invocations in dist test -compile-only

    For the misccompile builders, the builds that are run after
    the initial go test -c std cmd already have GOMAXPROCS concurrency
    per build. Limit the concurrency of the number of builds that run
    in parallel to avoid oversubscribing the CPU.

    Change-Id: Id1954aeb2881c32d9b5bf1c2602d506b6a6a6964
    Reviewed-on: https://go-review.googlesource.com/c/go/+/867588
    LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
    Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
    Reviewed-by: Michael Matloob <matloob@google.com>

diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index d6cb839a91..0fdf37f540 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -1573,6 +1573,12 @@ func (t *tester) runPending(nextTest *distTest) {
 		pendingSpan = startSpan("runPending")
 	}
 	maxbg := runtime.GOMAXPROCS(0)
+	if t.compileOnly {
+		// go build is decently well parallelized.
+		// Avoid running too many builds which each
+		// already run GOMAXPROCS actions concurrently.
+		maxbg = min(maxbg, max(2, maxbg/4))
+	}
 	capProcs := len(worklist) > 1 && t.hasParallelism() && !isEnvSet("GOMAXPROCS") && maxbg > maxTestGOMAXPROCS
 	for i, w := range worklist {
 		if capProcs && !slices.ContainsFunc(w.cmd.Env, func(kv string) bool { return strings.HasPrefix(kv, "GOMAXPROCS=") }) {