]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix GC assist retry path
authorAustin Clements <austin@google.com>
Mon, 10 Oct 2016 16:18:00 +0000 (12:18 -0400)
committerAustin Clements <austin@google.com>
Mon, 17 Oct 2016 19:09:37 +0000 (19:09 +0000)
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>
src/runtime/mgcmark.go

index 286563752cc34b14fc0b7e6cd2a02ad27ab81140..5dd7c52b214ea54a794a018b5e8aa7c9f126c17c 100644 (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