Commit aa9ae07ce5 for golang

commit aa9ae07ce51ea869f3885c128d97e418da2f947a
Author: Mark Freeman <mark@golang.org>
Date:   Thu Dec 3 16:21:45 2026 -0500

    cmd/compile/internal/contraire: make timeout configurable

    The longtest builders are a bit congested and need a longer timeout,
    which doesn't make sense on local laptop runs and needlessly slows
    things down. Expose it as a knob with a sensible default.

    Change-Id: Id7afa061ae9af6c6f912970fd9fd8066314b8662
    Reviewed-on: https://go-review.googlesource.com/c/go/+/869264
    Auto-Submit: Mark Freeman <mark@golang.org>
    Reviewed-by: Robert Griesemer <gri@google.com>
    TryBot-Bypass: Mark Freeman <mark@golang.org>

diff --git a/src/cmd/compile/internal/contraire/contraire_test.go b/src/cmd/compile/internal/contraire/contraire_test.go
index fac3567551..174b00125b 100644
--- a/src/cmd/compile/internal/contraire/contraire_test.go
+++ b/src/cmd/compile/internal/contraire/contraire_test.go
@@ -11,6 +11,7 @@ import (
 	"path/filepath"
 	"runtime"
 	"testing"
+	"time"
 )

 func TestContraire(t *testing.T) {
@@ -28,9 +29,8 @@ func TestContraire(t *testing.T) {
 		t.Fatalf("couldn't build worker binary: %v\n%s", err, out)
 	}

-	const trials = 100_000
 	for _, std := range [...]bool{false, true} {
-		out, err := RunDriver(exe, dir, trials, runtime.GOMAXPROCS(0), nil, std)
+		out, err := RunDriver(exe, dir, 100_000, runtime.GOMAXPROCS(0), 1*time.Second, nil, std)
 		if err != nil {
 			t.Fatal(err)
 		}
diff --git a/src/cmd/compile/internal/contraire/driver.go b/src/cmd/compile/internal/contraire/driver.go
index aa74daceea..b78a242c3d 100644
--- a/src/cmd/compile/internal/contraire/driver.go
+++ b/src/cmd/compile/internal/contraire/driver.go
@@ -20,7 +20,7 @@ import (

 // RunDriver manages workers that generate and type-check programs. It returns a
 // summary of the workers' outputs (or an error).
-func RunDriver(workerExe, workDir string, trials, workers int, cfg *Config, std bool) (*Output, error) {
+func RunDriver(workerExe, workDir string, trials, workers int, timeout time.Duration, cfg *Config, std bool) (*Output, error) {
 	if trials < 1 {
 		return nil, errors.New("trials must be positive")
 	}
@@ -28,6 +28,9 @@ func RunDriver(workerExe, workDir string, trials, workers int, cfg *Config, std
 		return nil, errors.New("workers must be positive")
 	}
 	workers = min(workers, trials)
+	if timeout < 1 {
+		return nil, errors.New("timeout must be positive")
+	}

 	// Recreate the driver directory in case a prior run didn't exit cleanly.
 	driverDir := filepath.Join(workDir, "contraire")
@@ -66,7 +69,7 @@ func RunDriver(workerExe, workDir string, trials, workers int, cfg *Config, std
 	}

 	// Monitor workers and reassign shards as-needed.
-	ticker := time.NewTicker(time.Second)
+	ticker := time.NewTicker(timeout)
 	defer ticker.Stop()

 	acc := &Output{}
diff --git a/src/cmd/compile/internal/contraire/main.go b/src/cmd/compile/internal/contraire/main.go
index d473277850..77b6c72246 100644
--- a/src/cmd/compile/internal/contraire/main.go
+++ b/src/cmd/compile/internal/contraire/main.go
@@ -14,6 +14,7 @@ import (
 	"log"
 	"os"
 	"runtime"
+	"time"
 )

 var (
@@ -23,6 +24,10 @@ var (
 	// parallel; each worker gets a process.
 	workers = flag.Int("workers", runtime.GOMAXPROCS(0), "number of worker processes")

+	// (Optional) Sets the timeout for a worker to make progress before the
+	// driver assumes it to be hanging.
+	timeout = flag.Duration("timeout", 100*time.Millisecond, "worker progress timeout")
+
 	// ============================= Shared Flags =============================

 	// (Optional) Sets the number of programs to generate.
@@ -81,7 +86,7 @@ func main() {
 		}
 	}

-	out, err := contraire.RunDriver(exe, os.TempDir(), *trials, *workers, cfg, *std)
+	out, err := contraire.RunDriver(exe, os.TempDir(), *trials, *workers, *timeout, cfg, *std)
 	if err != nil {
 		log.Fatal(err)
 	}