1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:54:57 -07:00

runtime: fix GC assist retry path

GC assists retry if preempted or if they fail to park. However, on the
retry path they currently use stale statistics. In particular, the
retry can use "debtBytes", but debtBytes isn't updated when the debt
changes (since other than retries it is only used once). Also, though
less of a problem, the if the assist ratio has changed while the
assist was blocked, the retry will still use the old assist ratio.

Fix all of this by simply making the retry jump back to where we
compute these statistics, rather than just after.

Change-Id: I2ed8b4f0fc9f008ff060aa926f4334b662ac7d3f
Reviewed-on: https://go-review.googlesource.com/30701
Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
Austin Clements 2016-10-10 12:18:00 -04:00
parent 81c431a537
commit 984753b665

View File

@ -406,6 +406,7 @@ func gcAssistAlloc(gp *g) {
return
}
retry:
// Compute the amount of scan work we need to do to make the
// balance positive. When the required amount of work is low,
// we over-assist to build up credit for future allocations
@ -417,7 +418,6 @@ func gcAssistAlloc(gp *g) {
debtBytes = int64(gcController.assistBytesPerWork * float64(scanWork))
}
retry:
// Steal as much credit as we can from the background GC's
// scan credit. This is racy and may drop the background
// credit below 0 if two mutators steal at the same time. This