From 984753b665875cd62f6144a42f6df58cb5f159a8 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 10 Oct 2016 12:18:00 -0400 Subject: [PATCH] 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 --- src/runtime/mgcmark.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 286563752c..5dd7c52b21 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -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 -- 2.48.1