From: Joel Sing Date: Wed, 5 Oct 2011 16:08:28 +0000 (-0400) Subject: gc: limit helper threads based on ncpu X-Git-Tag: weekly.2011-10-06~29 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a5f064a3e127b1d54853822a608137d3539b578f;p=gostls13.git gc: limit helper threads based on ncpu When ncpu < 2, work.nproc is always 1 which results in infinite helper threads being created if gomaxprocs > 1 and MaxGcproc > 1. Avoid this by using the same limits as imposed helpgc(). R=golang-dev, rsc, dvyukov CC=golang-dev https://golang.org/cl/5176044 --- diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index eaa056da0b..a2ae8a4109 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -984,8 +984,7 @@ runtime·gc(int32 force) // coordinate. This lazy approach works out in practice: // we don't mind if the first couple gc rounds don't have quite // the maximum number of procs. - extra = work.nproc < runtime·gomaxprocs && work.nproc < MaxGcproc; - + extra = work.nproc < runtime·gomaxprocs && work.nproc < runtime·ncpu && work.nproc < MaxGcproc; runtime·starttheworld(extra); // give the queued finalizers, if any, a chance to run