]> Cypherpunks repositories - gostls13.git/commit
runtime: report GC CPU utilization in MemStats
authorAustin Clements <austin@google.com>
Wed, 29 Jul 2015 18:02:34 +0000 (14:02 -0400)
committerAustin Clements <austin@google.com>
Wed, 29 Jul 2015 20:23:34 +0000 (20:23 +0000)
commit23e4744c07f78151a4e9fa5187b84ed26fe3628b
treedb6111eb8c6ad267840ce84adc4bd2130d83c901
parent4b71660c5b84a2c47f206145a9913f4418330b59
runtime: report GC CPU utilization in MemStats

This adds a GCCPUFraction field to MemStats that reports the
cumulative fraction of the program's execution time spent in the
garbage collector. This is equivalent to the utilization percent shown
in the gctrace output and makes this available programmatically.

This does make one small effect on the gctrace output: we now report
the duration of mark termination up to just before the final
start-the-world, rather than up to just after. However, unlike
stop-the-world, I don't believe there's any way that start-the-world
can block, so it should take negligible time.

While there are many statistics one might want to expose via MemStats,
this is one of the few that will undoubtedly remain meaningful
regardless of future changes to the memory system.

The diff for this change is larger than the actual change. Mostly it
lifts the code for computing the GC CPU utilization out of the
debug.gctrace path.

Updates #10323.

Change-Id: I0f7dc3fdcafe95e8d1233ceb79de606b48acd989
Reviewed-on: https://go-review.googlesource.com/12844
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go
src/runtime/mstats.go