]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reset sweep stats before starting the world
authorAustin Clements <austin@google.com>
Mon, 14 Dec 2015 20:07:40 +0000 (15:07 -0500)
committerAustin Clements <austin@google.com>
Tue, 15 Dec 2015 17:58:22 +0000 (17:58 +0000)
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 <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go

index 9f8c505c6bb22e774c4cceb7e25c460a3192ddb8..878734b3772215c64ae5f421f0fb7c3525fcc83d 100644 (file)
@@ -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 {