]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: simplify heap profile flushing
authorAustin Clements <austin@google.com>
Thu, 2 Mar 2017 02:03:20 +0000 (21:03 -0500)
committerAustin Clements <austin@google.com>
Fri, 31 Mar 2017 01:15:01 +0000 (01:15 +0000)
Currently the heap profile is flushed by *either* gcSweep in STW mode
or by gcMarkTermination in concurrent mode. Simplify this by making
gcMarkTermination always flush the heap profile and by making gcSweep
do one extra flush (instead of two) in STW mode.

Change-Id: I62147afb2a128e1f3d92ef4bb8144c8a345f53c4
Reviewed-on: https://go-review.googlesource.com/37715
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go

index 31e8e4caeefb3783fea9b61f26354c1bbae16491..0d4178dd9e45fbb2018611dfdeabb8f9fd58d6e9 100644 (file)
@@ -1302,23 +1302,17 @@ func gcMarkTermination() {
        sweep.nbgsweep = 0
        sweep.npausesweep = 0
 
-       // If gcSweep didn't do it, finish the current heap profiling
-       // cycle and start a new heap profiling cycle. We do this
-       // before starting the world so events don't leak into the
-       // wrong cycle.
-       needProfCycle := _ConcurrentSweep && work.mode != gcForceBlockMode
-       if needProfCycle {
-               mProf_NextCycle()
-       }
+       // Finish the current heap profiling cycle and start a new
+       // heap profiling cycle. We do this before starting the world
+       // so events don't leak into the wrong cycle.
+       mProf_NextCycle()
 
        systemstack(startTheWorldWithSema)
 
        // Flush the heap profile so we can start a new cycle next GC.
        // This is relatively expensive, so we don't do it with the
        // world stopped.
-       if needProfCycle {
-               mProf_Flush()
-       }
+       mProf_Flush()
 
        // Free stack spans. This must be done between GC cycles.
        systemstack(freeStackSpans)
@@ -1763,10 +1757,9 @@ func gcSweep(mode gcMode) {
                for sweepone() != ^uintptr(0) {
                        sweep.npausesweep++
                }
-               // All "free" events are now real, so flush everything
-               // into the published profile.
-               mProf_NextCycle()
-               mProf_Flush()
+               // All "free" events for this mark/sweep cycle have
+               // now happened, so we can make this profile cycle
+               // available immediately.
                mProf_NextCycle()
                mProf_Flush()
                return