Skip to content

Commit

Permalink
runtime: report marked heap size in gctrace
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aclements committed Apr 6, 2015
1 parent 6d12b17 commit 8c3fc08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime/mgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)")
Expand Down

0 comments on commit 8c3fc08

Please sign in to comment.