From 7f0929e5198bb9439a4304085979a7e2e46c6a2d Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 20 Aug 2022 12:10:48 +0200 Subject: [PATCH] helper: Reduce number of parallel builds a bit The go compiler is already parallelized. The high concurrency caused my podman container to hit a resource limit. --- helpers/build-release-binaries/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/build-release-binaries/main.go b/helpers/build-release-binaries/main.go index b176f8b8c..df6c4d2bf 100644 --- a/helpers/build-release-binaries/main.go +++ b/helpers/build-release-binaries/main.go @@ -182,14 +182,19 @@ func buildForTarget(sourceDir, outputDir, goos, goarch string) (filename string) func buildTargets(sourceDir, outputDir string, targets map[string][]string) { start := time.Now() - msg("building with %d workers", runtime.NumCPU()) + // the go compiler is already parallelized, thus reduce the concurrency a bit + workers := runtime.GOMAXPROCS(0) / 4 + if workers < 1 { + workers = 1 + } + msg("building with %d workers", workers) type Job struct{ GOOS, GOARCH string } var wg errgroup.Group ch := make(chan Job) - for i := 0; i < runtime.NumCPU(); i++ { + for i := 0; i < workers; i++ { wg.Go(func() error { for job := range ch { start := time.Now()