aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgcpacer.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-04-08 22:01:13 +0000
committerMichael Knyszek <mknyszek@google.com>2021-10-21 18:20:19 +0000
commitf99e40aac023d818e8c2594e5b8c075786087132 (patch)
treeb190f9eb7f50b05819cc09f24d0b2b1a8c209dcb /src/runtime/mgcpacer.go
parent6508fdad9d83d6792314639c9819a15894728682 (diff)
downloadgo-f99e40aac023d818e8c2594e5b8c075786087132.tar.gz
go-f99e40aac023d818e8c2594e5b8c075786087132.zip
runtime: detangle gcPaceScavenger from the pacer
Currently gcPaceScavenger is called by gcControllerState.commit, but it manipulates global state which precludes testing. This change detangles the two. Change-Id: I10d8ebdf426d99ba49d2f2cb4fb64891e9fd6091 Reviewed-on: https://go-review.googlesource.com/c/go/+/309272 Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/runtime/mgcpacer.go')
-rw-r--r--src/runtime/mgcpacer.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go
index 44b870446f..73fe6e15e4 100644
--- a/src/runtime/mgcpacer.go
+++ b/src/runtime/mgcpacer.go
@@ -769,8 +769,6 @@ func (c *gcControllerState) commit(triggerRatio float64) {
mheap_.pagesSweptBasis.Store(pagesSwept)
}
}
-
- gcPaceScavenger()
}
// effectiveGrowthRatio returns the current effective heap growth
@@ -796,6 +794,8 @@ func (c *gcControllerState) effectiveGrowthRatio() float64 {
// setGCPercent updates gcPercent and all related pacer state.
// Returns the old value of gcPercent.
//
+// Calls gcControllerState.commit.
+//
// The world must be stopped, or mheap_.lock must be held.
func (c *gcControllerState) setGCPercent(in int32) int32 {
assertWorldStoppedOrLockHeld(&mheap_.lock)
@@ -819,6 +819,7 @@ func setGCPercent(in int32) (out int32) {
systemstack(func() {
lock(&mheap_.lock)
out = gcController.setGCPercent(in)
+ gcPaceScavenger(gcController.heapGoal, gcController.lastHeapGoal)
unlock(&mheap_.lock)
})