Skip to content

Commit

Permalink
chore: backup GOMAXPROCS
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 12, 2024
1 parent 4fa63cc commit 3f4b50d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, _ []string) error {
}

if c.cfg.Run.Concurrency == 0 {
backup := runtime.GOMAXPROCS(0)

// Automatically set GOMAXPROCS to match Linux container CPU quota.
_, _ = maxprocs.Set(maxprocs.Logger(c.log.Infof))
_, err := maxprocs.Set(maxprocs.Logger(c.log.Infof))
if err != nil {
runtime.GOMAXPROCS(backup)
}
} else {
runtime.GOMAXPROCS(c.cfg.Run.Concurrency)
}
Expand Down

0 comments on commit 3f4b50d

Please sign in to comment.