summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-02-15 17:44:40 +0100
committerJakob Unterwurzacher2020-02-15 17:44:40 +0100
commitff210a06fb3097eecd5668ddb3ace9c76873eb00 (patch)
tree35449db8c7ad8db0cbde9c8f8afed67eaf94811e
parentd5ce340c02601992cc9dab1bd7d3c2d95d81155e (diff)
main: respect GOMAXPROCS environment variable
If the user sets GOMAXPROCS explicitely, we should respect it.
-rw-r--r--main.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.go b/main.go
index 2aad353..76cd275 100644
--- a/main.go
+++ b/main.go
@@ -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