From b8526a83804fa3e75ee3fc2a3a55f27791f6bd8f Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 22 Jul 2015 16:40:50 -0400 Subject: [PATCH] runtime: steal the correct amount of GC assist credit 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 Reviewed-by: Russ Cox --- 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 c7d175b1f8..9212b2edc6 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -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 -- 2.48.1