mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +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
1 changed files with 7 additions and 2 deletions
|
@ -182,14 +182,19 @@ func buildForTarget(sourceDir, outputDir, goos, goarch string) (filename string)
|
||||||
|
|
||||||
func buildTargets(sourceDir, outputDir string, targets map[string][]string) {
|
func buildTargets(sourceDir, outputDir string, targets map[string][]string) {
|
||||||
start := time.Now()
|
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 }
|
type Job struct{ GOOS, GOARCH string }
|
||||||
|
|
||||||
var wg errgroup.Group
|
var wg errgroup.Group
|
||||||
ch := make(chan Job)
|
ch := make(chan Job)
|
||||||
|
|
||||||
for i := 0; i < runtime.NumCPU(); i++ {
|
for i := 0; i < workers; i++ {
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
for job := range ch {
|
for job := range ch {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
Loading…
Reference in a new issue