Skip to content

Commit ff210a0

Browse files
committed
main: respect GOMAXPROCS environment variable
If the user sets GOMAXPROCS explicitely, we should respect it.
1 parent d5ce340 commit ff210a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ func printVersion() {
133133

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

0 commit comments

Comments
 (0)