From: Heschi Kreinick Date: Wed, 8 Dec 2021 20:29:12 +0000 (-0500) Subject: cmd/api: run half as many go list calls in parallel X-Git-Tag: go1.18beta1~40 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bb9b20a15d637667614ec4a312f216bd4c67b76a;p=gostls13.git cmd/api: run half as many go list calls in parallel We currently run one 'go list' invocation per GOMAXPROC. Since the go command uses memory and has its own internal parallelism, that's unlikely to be an efficient use of resources. Run half as many. I suspect that's still too many but this should fix our OOMs. For #49957. Change-Id: Id06b6e0f0d96387a2a050e400f38bde6ba71aa60 Reviewed-on: https://go-review.googlesource.com/c/go/+/370376 Trust: Heschi Kreinick Run-TryBot: Heschi Kreinick Reviewed-by: Bryan Mills --- diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 0c61b1b489..a55e51cc9b 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -460,7 +460,7 @@ type listImports struct { var listCache sync.Map // map[string]listImports, keyed by contextName // listSem is a semaphore restricting concurrent invocations of 'go list'. -var listSem = make(chan semToken, runtime.GOMAXPROCS(0)) +var listSem = make(chan semToken, ((runtime.GOMAXPROCS(0)-1)/2)+1) type semToken struct{}