Commit 8c3fc088 authored by Austin Clements's avatar Austin Clements

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/8430Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
parent 6d12b178
......@@ -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)")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment