From 7eeeae2a5cc5087347c2fcdfc9731c87143dab4a Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 21 Jul 2015 11:38:14 -0400 Subject: [PATCH] runtime: always report starting heap size in gctrace Currently the gctrace output reports the trigger heap size, rather than the actual heap size at the beginning of GC. Often these are the same, or at least very close. However, it's possible for the heap to already have exceeded this trigger when we first check the trigger and start GC; in this case, this output is very misleading. We've encountered this confusion a few times when debugging and this behavior is difficult to document succinctly. Change the gctrace output to report the actual heap size when GC starts, rather than the trigger. Change-Id: I246b3ccae4c4c7ea44c012e70d24a46878d7601f Reviewed-on: https://go-review.googlesource.com/12452 Reviewed-by: Russ Cox --- src/runtime/mgc.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 8731dd8511..889abfbbc9 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -884,14 +884,7 @@ func gc(mode int) { if debug.gctrace > 0 { stwprocs, maxprocs = gcprocs(), gomaxprocs tSweepTerm = now - if mode == gcBackgroundMode { - // We started GC when heap_live == next_gc, - // but the mutator may have allocated between - // then and now. Report heap when GC started. - heap0 = memstats.next_gc - } else { - heap0 = memstats.heap_live - } + heap0 = memstats.heap_live } pauseStart = now -- 2.50.0