diff options
-rw-r--r-- | src/runtime/mgc.go | 9 | ||||
-rw-r--r-- | src/runtime/mgcmark.go | 11 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 1eabf43d6f..3b238cba1c 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -741,11 +741,10 @@ const gcCreditSlack = 2000 // can accumulate on a P before updating gcController.assistTime. const gcAssistTimeSlack = 5000 -// gcOverAssistBytes determines how many extra allocation bytes of -// assist credit a GC assist builds up when an assist happens. This -// amortizes the cost of an assist by pre-paying for this many bytes -// of future allocations. -const gcOverAssistBytes = 1 << 20 +// gcOverAssistWork determines how many extra units of scan work a GC +// assist does when an assist happens. This amortizes the cost of an +// assist by pre-paying for this many bytes of future allocations. +const gcOverAssistWork = 64 << 10 var work struct { full uint64 // lock-free list of full blocks workbuf diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 00b96fd00b..aa7f7a7769 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -393,10 +393,15 @@ func gcAssistAlloc(gp *g) { } // Compute the amount of scan work we need to do to make the - // balance positive. We over-assist to build up credit for - // future allocations and amortize the cost of assisting. - debtBytes := -gp.gcAssistBytes + gcOverAssistBytes + // balance positive. When the required amount of work is low, + // we over-assist to build up credit for future allocations + // and amortize the cost of assisting. + debtBytes := -gp.gcAssistBytes scanWork := int64(gcController.assistWorkPerByte * float64(debtBytes)) + if scanWork < gcOverAssistWork { + scanWork = gcOverAssistWork + debtBytes = int64(gcController.assistBytesPerWork * float64(scanWork)) + } retry: // Steal as much credit as we can from the background GC's |