diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-02-12 20:35:50 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-02-15 09:12:18 -0800 |
commit | 17edb3310d8ce9d5f6c9e53f6c1f7d611c2a5a41 (patch) | |
tree | 3979912a6fd0b36187ca8367874dbe8b299b310d /libgo | |
parent | 5599262661af219726dccba200459671ed7bba8a (diff) | |
download | gcc-17edb3310d8ce9d5f6c9e53f6c1f7d611c2a5a41.zip gcc-17edb3310d8ce9d5f6c9e53f6c1f7d611c2a5a41.tar.gz gcc-17edb3310d8ce9d5f6c9e53f6c1f7d611c2a5a41.tar.bz2 |
runtime: on 32-bit systems, limit default GOMAXPROCS to 32
Otherwise we can easily run out of stack space for threads.
The user can still override by setting GOMAXPROCS.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/219278
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/runtime/proc.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index c0e8577..e3f934a 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -563,6 +563,14 @@ func schedinit() { sched.lastpoll = uint64(nanotime()) procs := ncpu + + // In 32-bit mode, we can burn a lot of memory on thread stacks. + // Try to avoid this by limiting the number of threads we run + // by default. + if sys.PtrSize == 4 && procs > 32 { + procs = 32 + } + if n, ok := atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 { procs = n } |