From: Austin Clements Date: Mon, 14 Dec 2015 20:07:40 +0000 (-0500) Subject: runtime: reset sweep stats before starting the world X-Git-Tag: go1.6beta1~80 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ff5c94538292ca66543603fc78c02a96c823c6aa;p=gostls13.git runtime: reset sweep stats before starting the world Currently we reset the sweep stats just after gcMarkTermination starts the world and releases worldsema. However, background sweeping can start the moment we start the world and, in fact, pause sweeping can start the moment we release worldsema (because another GC cycle can start up), so these need to be cleared before starting the world. Change-Id: I95701e3de6af76bb3fbf2ee65719985bf57d20b2 Reviewed-on: https://go-review.googlesource.com/17811 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 9f8c505c6b..878734b377 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1245,6 +1245,10 @@ func gcMarkTermination() { memstats.numgc++ + // Reset sweep state. + sweep.nbgsweep = 0 + sweep.npausesweep = 0 + systemstack(startTheWorldWithSema) // Free stack spans. This must be done between GC cycles. @@ -1301,8 +1305,6 @@ func gcMarkTermination() { print("\n") printunlock() } - sweep.nbgsweep = 0 - sweep.npausesweep = 0 // now that gc is done, kick off finalizer thread if needed if !concurrentSweep {