diff options
author | Austin Clements <austin@google.com> | 2015-08-03 18:06:05 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2015-08-04 18:54:53 +0000 |
commit | e3870aa6f38b842ba5527a1ccd9433f8b6a4a2fe (patch) | |
tree | cd34c70cec40a16319c6654fda191bdcdb4b6d6d | |
parent | 1fb01a88f94e9ec5477ae3608ece2e69b5d51442 (diff) | |
download | go-e3870aa6f38b842ba5527a1ccd9433f8b6a4a2fe.tar.gz go-e3870aa6f38b842ba5527a1ccd9433f8b6a4a2fe.zip |
runtime: fix assist utilization computation
When commit 510fd13 enabled assists during the scan phase, it failed
to also update the code in the GC controller that computed the assist
CPU utilization and adjusted the trigger based on it. Fix that code so
it uses the start of the scan phase as the wall-clock time when
assists were enabled rather than the start of the mark phase.
Change-Id: I05013734b4448c3e2c730dc7b0b5ee28c86ed8cf
Reviewed-on: https://go-review.googlesource.com/13048
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
-rw-r--r-- | src/runtime/mgc.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 6d4799a9e2..c8031d7db7 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -348,6 +348,10 @@ type gcControllerState struct { // that the background mark phase started. bgMarkStartTime int64 + // assistTime is the absolute start time in nanoseconds that + // mutator assists were enabled. + assistStartTime int64 + // heapGoal is the goal memstats.heap_live for when this cycle // ends. This is computed at the beginning of each cycle. heapGoal uint64 @@ -500,15 +504,19 @@ func (c *gcControllerState) endCycle() { // growth if we had the desired CPU utilization). The // difference between this estimate and the GOGC-based goal // heap growth is the error. + // + // TODO(austin): next_gc is based on heap_reachable, not + // heap_marked, which means the actual growth ratio + // technically isn't comparable to the trigger ratio. goalGrowthRatio := float64(gcpercent) / 100 actualGrowthRatio := float64(memstats.heap_live)/float64(memstats.heap_marked) - 1 - duration := nanotime() - c.bgMarkStartTime + assistDuration := nanotime() - c.assistStartTime // Assume background mark hit its utilization goal. utilization := gcGoalUtilization // Add assist utilization; avoid divide by zero. - if duration > 0 { - utilization += float64(c.assistTime) / float64(duration*int64(gomaxprocs)) + if assistDuration > 0 { + utilization += float64(c.assistTime) / float64(assistDuration*int64(gomaxprocs)) } triggerError := goalGrowthRatio - c.triggerRatio - utilization/gcGoalUtilization*(actualGrowthRatio-c.triggerRatio) @@ -979,6 +987,7 @@ func gc(mode int) { now = nanotime() pauseNS += now - pauseStart tScan = now + gcController.assistStartTime = now gcscan_m() // Enter mark phase. |