aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgcpacer.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-04-01 16:31:29 +0000
committerMichael Knyszek <mknyszek@google.com>2021-04-14 03:14:51 +0000
commit728e3dc6f9c900654d94642135e0dcfe2f7bb645 (patch)
treedecdd3f95a18f192961b4aea40e218ce1c9428f9 /src/runtime/mgcpacer.go
parenteb433ed5a2ab13567cd5d7f0413308174750d5dd (diff)
downloadgo-728e3dc6f9c900654d94642135e0dcfe2f7bb645.tar.gz
go-728e3dc6f9c900654d94642135e0dcfe2f7bb645.zip
runtime: make gcSetTriggerRatio a method of gcControllerState
gcSetTriggerRatio's purpose is to set a bunch of downstream values when we choose to commit to a new trigger ratio computed by the gcController. Now that almost all the inputs it uses to compute the downstream values are in gcControllerState anyway, make it a method of gcControllerState. For #44167. Change-Id: I1b7ea709e8378566f812ae3450ab169d7fb66aea Reviewed-on: https://go-review.googlesource.com/c/go/+/306599 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mgcpacer.go')
-rw-r--r--src/runtime/mgcpacer.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go
index 1239ba4bb8..51cb3bb1b9 100644
--- a/src/runtime/mgcpacer.go
+++ b/src/runtime/mgcpacer.go
@@ -606,7 +606,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
return gp
}
-// gcSetTriggerRatio sets the trigger ratio and updates everything
+// commit sets the trigger ratio and updates everything
// derived from it: the absolute trigger, the heap goal, mark pacing,
// and sweep pacing.
//
@@ -617,7 +617,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
// gcController.heapLive. These must be up to date.
//
// mheap_.lock must be held or the world must be stopped.
-func gcSetTriggerRatio(triggerRatio float64) {
+func (c *gcControllerState) commit(triggerRatio float64) {
assertWorldStoppedOrLockHeld(&mheap_.lock)
// Compute the next GC goal, which is when the allocated heap
@@ -625,7 +625,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// cycle.
goal := ^uint64(0)
if gcPercent >= 0 {
- goal = gcController.heapMarked + gcController.heapMarked*uint64(gcPercent)/100
+ goal = c.heapMarked + c.heapMarked*uint64(gcPercent)/100
}
// Set the trigger ratio, capped to reasonable bounds.
@@ -663,7 +663,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// certainly undesirable.
triggerRatio = 0
}
- gcController.triggerRatio = triggerRatio
+ c.triggerRatio = triggerRatio
// Compute the absolute GC trigger from the trigger ratio.
//
@@ -671,7 +671,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// grown by the trigger ratio over the marked heap size.
trigger := ^uint64(0)
if gcPercent >= 0 {
- trigger = uint64(float64(gcController.heapMarked) * (1 + triggerRatio))
+ trigger = uint64(float64(c.heapMarked) * (1 + triggerRatio))
// Don't trigger below the minimum heap size.
minTrigger := heapMinimum
if !isSweepDone() {
@@ -680,7 +680,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// that concurrent sweep has some heap growth
// in which to perform sweeping before we
// start the next GC cycle.
- sweepMin := atomic.Load64(&gcController.heapLive) + sweepMinHeapDistance
+ sweepMin := atomic.Load64(&c.heapLive) + sweepMinHeapDistance
if sweepMin > minTrigger {
minTrigger = sweepMin
}
@@ -689,7 +689,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
trigger = minTrigger
}
if int64(trigger) < 0 {
- print("runtime: next_gc=", memstats.next_gc, " heapMarked=", gcController.heapMarked, " gcController.heapLive=", gcController.heapLive, " initialHeapLive=", work.initialHeapLive, "triggerRatio=", triggerRatio, " minTrigger=", minTrigger, "\n")
+ print("runtime: next_gc=", memstats.next_gc, " heapMarked=", c.heapMarked, " gcController.heapLive=", c.heapLive, " initialHeapLive=", work.initialHeapLive, "triggerRatio=", triggerRatio, " minTrigger=", minTrigger, "\n")
throw("trigger underflow")
}
if trigger > goal {
@@ -701,7 +701,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
}
// Commit to the trigger and goal.
- gcController.trigger = trigger
+ c.trigger = trigger
atomic.Store64(&memstats.next_gc, goal)
if trace.enabled {
traceNextGC()
@@ -709,7 +709,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// Update mark pacing.
if gcphase != _GCoff {
- gcController.revise()
+ c.revise()
}
// Update sweep pacing.
@@ -721,7 +721,7 @@ func gcSetTriggerRatio(triggerRatio float64) {
// trigger. Compute the ratio of in-use pages to sweep
// per byte allocated, accounting for the fact that
// some might already be swept.
- heapLiveBasis := atomic.Load64(&gcController.heapLive)
+ heapLiveBasis := atomic.Load64(&c.heapLive)
heapDistance := int64(trigger) - int64(heapLiveBasis)
// Add a little margin so rounding errors and
// concurrent sweep are less likely to leave pages
@@ -781,7 +781,7 @@ func setGCPercent(in int32) (out int32) {
gcPercent = in
heapMinimum = defaultHeapMinimum * uint64(gcPercent) / 100
// Update pacing in response to gcPercent change.
- gcSetTriggerRatio(gcController.triggerRatio)
+ gcController.commit(gcController.triggerRatio)
unlock(&mheap_.lock)
})