From e9cc31e736a6a1931ab010a2fda0e5d0ac4e5127 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Thu, 1 Apr 2021 19:09:40 +0000 Subject: [PATCH] runtime: pass work.userForced to gcController.endCycle explicitly For #44167. Change-Id: I15817006f1870d6237cd06dabad988da3f23a6d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/306604 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/mgc.go | 2 +- src/runtime/mgcpacer.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index bb98cf29bc..e4bbf1f016 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 ba16c59052..6bf3e3f278 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. -- 2.50.0