Skip to content

Commit 506d6c1

Browse files
committed
Use GOMAXPROCS floor of 32 instead of forcing NumCPU
1 parent 7582d57 commit 506d6c1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cmd/gradle-cache/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,12 @@ func projectDirSources(projectDir string, includedBuilds []string) []tarSource {
721721
}
722722

723723
func main() {
724-
// Override GOMAXPROCS: the environment may set it to a small value (e.g. 2)
725-
// that starves the zstd decoder and tar pipeline when competing with the
726-
// file-writing goroutine pool. Using all available CPUs gives the decoder
727-
// and scheduler room to run at full throughput.
728-
runtime.GOMAXPROCS(runtime.NumCPU())
724+
// Ensure GOMAXPROCS is at least 32 for I/O-bound workloads, regardless
725+
// of cgroup CPU limits. The file-write goroutine pool and zstd decoder
726+
// need OS threads for blocking syscalls, not CPU time.
727+
if runtime.GOMAXPROCS(0) < 32 {
728+
runtime.GOMAXPROCS(32)
729+
}
729730

730731
cli := &CLI{}
731732
ctx := context.Background()

0 commit comments

Comments
 (0)