From: Austin Clements Date: Mon, 14 Dec 2015 20:38:12 +0000 (-0500) Subject: runtime: update triggerRatio in setGCPercent X-Git-Tag: go1.6beta1~78 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2bacae815b853522d8f6bbd82156f1e1c20482cb;p=gostls13.git runtime: update triggerRatio in setGCPercent Currently, runtime/debug.SetGCPercent does not adjust the controller trigger ratio. As a result, runtime reductions of GOGC don't take full effect until after one more concurrent cycle has happened, which adjusts the trigger ratio to account for the new gcpercent. Fix this by lowering the trigger ratio if necessary in setGCPercent. Change-Id: I4d23e0c58d91939b86ac60fa5d53ef91d0d89e0c Reviewed-on: https://go-review.googlesource.com/17813 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 756d74e4fd..01b72eea54 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -202,6 +202,9 @@ func setGCPercent(in int32) (out int32) { } gcpercent = in heapminimum = defaultHeapMinimum * uint64(gcpercent) / 100 + if gcController.triggerRatio > float64(gcpercent)/100 { + gcController.triggerRatio = float64(gcpercent) / 100 + } unlock(&mheap_.lock) return out }