diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index bb98cf29bc3..e4bbf1f016a 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -898,7 +898,7 @@ top: // endCycle depends on all gcWork cache stats being flushed. // The termination algorithm above ensured that up to // allocations since the ragged barrier. - nextTriggerRatio := gcController.endCycle() + nextTriggerRatio := gcController.endCycle(work.userForced) // Perform mark termination. This will restart the world. gcMarkTermination(nextTriggerRatio) diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index ba16c590520..6bf3e3f2788 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -444,8 +444,10 @@ func (c *gcControllerState) revise() { } // endCycle computes the trigger ratio for the next cycle. -func (c *gcControllerState) endCycle() float64 { - if work.userForced { +// userForced indicates whether the current GC cycle was forced +// by the application. +func (c *gcControllerState) endCycle(userForced bool) float64 { + if userForced { // Forced GC means this cycle didn't start at the // trigger, so where it finished isn't good // information about how to adjust the trigger.