1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

runtime: report marked heap size in gctrace

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>
This commit is contained in:
Austin Clements 2015-04-02 19:53:02 -04:00
parent 6d12b1780e
commit 8c3fc088fb

View 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)")