Skip to content

Commit

Permalink
main: respect GOMAXPROCS environment variable
Browse files Browse the repository at this point in the history
If the user sets GOMAXPROCS explicitely, we should
respect it.
  • Loading branch information
rfjakob committed Feb 15, 2020
1 parent d5ce340 commit ff210a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ func printVersion() {

func main() {
mxp := runtime.GOMAXPROCS(0)
if mxp < 4 {
// On a 2-core machine, setting maxprocs to 4 gives 10% better performance
if mxp < 4 && os.Getenv("GOMAXPROCS") == "" {
// On a 2-core machine, setting maxprocs to 4 gives 10% better performance.
// But don't override an explicitely set GOMAXPROCS env variable.
runtime.GOMAXPROCS(4)
}
// mount(1) unsets PATH. Since exec.Command does not handle this case, we set
Expand Down

0 comments on commit ff210a0

Please sign in to comment.