]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: always capture GC phase transition times
authorAustin Clements <austin@google.com>
Wed, 29 Jul 2015 16:48:33 +0000 (12:48 -0400)
committerAustin Clements <austin@google.com>
Wed, 29 Jul 2015 20:23:25 +0000 (20:23 +0000)
Currently we only capture GC phase transition times if
debug.gctrace>0, but we're about to compute GC CPU utilization
regardless of whether debug.gctrace is set, so we need these
regardless of debug.gctrace.

Change-Id: If3acf16505a43d416e9a99753206f03287180660
Reviewed-on: https://go-review.googlesource.com/12843
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go

index 0fdcc0f0c8274d934a7be0fb9b5b4bddd50581e7..56e5d578d59dea031b7ffd7bf30d1549230fb405 100644 (file)
@@ -880,9 +880,11 @@ func backgroundgc() {
 }
 
 func gc(mode int) {
-       // debug.gctrace variables
+       // Timing/utilization tracking
        var stwprocs, maxprocs int32
        var tSweepTerm, tScan, tInstallWB, tMark, tMarkTerm int64
+
+       // debug.gctrace variables
        var heap0, heap1, heap2, heapGoal uint64
 
        // memstats statistics
@@ -910,11 +912,9 @@ func gc(mode int) {
                gcBgMarkStartWorkers()
        }
        now = nanotime()
-       if debug.gctrace > 0 {
-               stwprocs, maxprocs = gcprocs(), gomaxprocs
-               tSweepTerm = now
-               heap0 = memstats.heap_live
-       }
+       stwprocs, maxprocs = gcprocs(), gomaxprocs
+       tSweepTerm = now
+       heap0 = memstats.heap_live
 
        pauseStart = now
        systemstack(stopTheWorldWithSema)
@@ -970,15 +970,11 @@ func gc(mode int) {
                        startTheWorldWithSema()
                        now = nanotime()
                        pauseNS += now - pauseStart
-                       if debug.gctrace > 0 {
-                               tScan = now
-                       }
+                       tScan = now
                        gcscan_m()
 
                        // Enter mark phase.
-                       if debug.gctrace > 0 {
-                               tInstallWB = nanotime()
-                       }
+                       tInstallWB = nanotime()
                        setGCPhase(_GCmark)
                        // Ensure all Ps have observed the phase
                        // change and have write barriers enabled
@@ -986,9 +982,7 @@ func gc(mode int) {
                        forEachP(func(*p) {})
                })
                // Concurrent mark.
-               if debug.gctrace > 0 {
-                       tMark = nanotime()
-               }
+               tMark = nanotime()
 
                // Enable background mark workers and wait for
                // background mark completion.
@@ -1022,9 +1016,7 @@ func gc(mode int) {
 
                // Begin mark termination.
                now = nanotime()
-               if debug.gctrace > 0 {
-                       tMarkTerm = now
-               }
+               tMarkTerm = now
                pauseStart = now
                systemstack(stopTheWorldWithSema)
                // The gcphase is _GCmark, it will transition to _GCmarktermination
@@ -1043,11 +1035,9 @@ func gc(mode int) {
                // such that mark termination scans all stacks.
                gcResetGState()
 
-               if debug.gctrace > 0 {
-                       t := nanotime()
-                       tScan, tInstallWB, tMark, tMarkTerm = t, t, t, t
-                       heapGoal = heap0
-               }
+               t := nanotime()
+               tScan, tInstallWB, tMark, tMarkTerm = t, t, t, t
+               heapGoal = heap0
        }
 
        // World is stopped.
@@ -1056,10 +1046,7 @@ func gc(mode int) {
        gcBlackenPromptly = false
        setGCPhase(_GCmarktermination)
 
-       if debug.gctrace > 0 {
-               heap1 = memstats.heap_live
-       }
-
+       heap1 = memstats.heap_live
        startTime := nanotime()
 
        mp := acquirem()
@@ -1077,9 +1064,7 @@ func gc(mode int) {
        // need to switch to g0 so we can shrink the stack.
        systemstack(func() {
                gcMark(startTime)
-               if debug.gctrace > 0 {
-                       heap2 = work.bytesMarked
-               }
+               heap2 = work.bytesMarked
                if debug.gccheckmark > 0 {
                        // Run a full stop-the-world mark using checkmark bits,
                        // to check that we didn't forget to mark anything during