mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
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.
This commit is contained in:
parent
ed94678820
commit
7f0929e519
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user