]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: steal the correct amount of GC assist credit
authorAustin Clements <austin@google.com>
Wed, 22 Jul 2015 20:40:50 +0000 (16:40 -0400)
committerAustin Clements <austin@google.com>
Mon, 27 Jul 2015 19:58:54 +0000 (19:58 +0000)
GC assists are supposed to steal at most the amount of background GC
credit available so that background GC credit doesn't go negative.
However, they are instead stealing the *total* amount of their debt
but only claiming up to the amount of credit that was available. This
results in draining the background GC credit pool too quickly, which
results in unnecessary assist work.

The fix is trivial: steal the amount of work we meant to steal (which
is already computed).

Change-Id: I837fe60ed515ba91c6baf363248069734a7895ef
Reviewed-on: https://go-review.googlesource.com/12643
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgcmark.go

index c7d175b1f8bbea3533125c150517eae4e9926f9f..9212b2edc6e371fc336ade909ce20fd776a99e9a 100644 (file)
@@ -182,7 +182,7 @@ func gcAssistAlloc(size uintptr, allowAssist bool) {
                } else {
                        stolen = scanWork
                }
-               xaddint64(&gcController.bgScanCredit, -scanWork)
+               xaddint64(&gcController.bgScanCredit, -stolen)
 
                scanWork -= stolen
                gp.gcscanwork += stolen