]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: report marked heap size in gctrace
authorAustin Clements <austin@google.com>
Thu, 2 Apr 2015 23:53:02 +0000 (19:53 -0400)
committerAustin Clements <austin@google.com>
Mon, 6 Apr 2015 21:28:23 +0000 (21:28 +0000)
When the gctrace GODEBUG option is enabled, it will now report three
heap sizes: the heap size at the beginning of the GC cycle, the heap
size at the end of the GC cycle before sweeping, and marked heap size,
which is the amount of heap that will be retained until the next GC
cycle.

Change-Id: Ie13f8a6d5c609bc9cc47c7555960ab55b37b5f1c
Reviewed-on: https://go-review.googlesource.com/8430
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go

index fc6fbd57682dfc1eb25c0fd1fe53cdcbdf0634e8..855430e48c7603969c363c5b7dc37a499338eeed 100644 (file)
@@ -294,7 +294,7 @@ func gc(mode int) {
        // debug.gctrace variables
        var stwprocs, maxprocs int32
        var tSweepTerm, tScan, tInstallWB, tMark, tMarkTerm int64
-       var heap0, heap1 uint64
+       var heap0, heap1, heap2 uint64
 
        // Ok, we're doing it!  Stop everybody else
        semacquire(&worldsema, false)
@@ -414,6 +414,9 @@ 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
+               }
                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
@@ -481,7 +484,6 @@ func gc(mode int) {
 
        memstats.numgc++
        if debug.gctrace > 0 {
-               // TODO(austin): Marked heap size at end
                tEnd := nanotime()
 
                // Update work.totaltime
@@ -512,7 +514,7 @@ func gc(mode int) {
                        "+", installWBCpu/1e6,
                        "+", markCpu/1e6,
                        "+", markTermCpu/1e6, " ms cpu, ",
-                       heap0>>20, "->", heap1>>20, " MB, ",
+                       heap0>>20, "->", heap1>>20, "->", heap2>>20, " MB, ",
                        maxprocs, " P")
                if mode != gcBackgroundMode {
                        print(" (forced)")