mirror of
https://github.com/golang/go
synced 2024-11-24 02:20:18 -07:00
runtime: clamp OS-reported number of processors to _MaxGomaxprocs
So that all Go processes do not die on startup on a system with >256 CPUs. I tested this by hacking osinit to set ncpu to 1000. Updates #15131 Change-Id: I52e061a0de97be41d684dd8b748fa9087d6f1aef Reviewed-on: https://go-review.googlesource.com/21599 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
a037c73ccf
commit
31cf1c1779
@ -449,6 +449,9 @@ func schedinit() {
|
||||
|
||||
sched.lastpoll = uint64(nanotime())
|
||||
procs := int(ncpu)
|
||||
if procs > _MaxGomaxprocs {
|
||||
procs = _MaxGomaxprocs
|
||||
}
|
||||
if n := atoi(gogetenv("GOMAXPROCS")); n > 0 {
|
||||
if n > _MaxGomaxprocs {
|
||||
n = _MaxGomaxprocs
|
||||
|
Loading…
Reference in New Issue
Block a user