]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: separate GC background utilization from goal utilization
authorAustin Clements <austin@google.com>
Wed, 4 Oct 2017 21:12:28 +0000 (17:12 -0400)
committerAustin Clements <austin@google.com>
Fri, 13 Oct 2017 20:52:45 +0000 (20:52 +0000)
Currently these are the same constant, but are separate concepts.
Split them into two constants for easier experimentation and better
documentation.

Change-Id: I121854d4fd1a4a827f727c8e5153160c24aacda7
Reviewed-on: https://go-review.googlesource.com/68570
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go

index d80e05c0f2586b2fa8ef1572f74ddbddab1b0fe9..32383736ec12fe153897ab68b24fec6302a8216b 100644 (file)
@@ -299,10 +299,10 @@ const (
 
        // gcMarkWorkerFractionalMode indicates that a P is currently
        // running the "fractional" mark worker. The fractional worker
-       // is necessary when GOMAXPROCS*gcGoalUtilization is not an
-       // integer. The fractional worker should run until it is
+       // is necessary when GOMAXPROCS*gcBackgroundUtilization is not
+       // an integer. The fractional worker should run until it is
        // preempted and will be scheduled to pick up the fractional
-       // part of GOMAXPROCS*gcGoalUtilization.
+       // part of GOMAXPROCS*gcBackgroundUtilization.
        gcMarkWorkerFractionalMode
 
        // gcMarkWorkerIdleMode indicates that a P is running the mark
@@ -453,9 +453,9 @@ func (c *gcControllerState) startCycle() {
                memstats.next_gc = memstats.heap_live + 1024*1024
        }
 
-       // Compute the total mark utilization goal and divide it among
+       // Compute the background mark utilization goal and divide it among
        // dedicated and fractional workers.
-       totalUtilizationGoal := float64(gomaxprocs) * gcGoalUtilization
+       totalUtilizationGoal := float64(gomaxprocs) * gcBackgroundUtilization
        c.dedicatedMarkWorkersNeeded = int64(totalUtilizationGoal)
        c.fractionalUtilizationGoal = totalUtilizationGoal - float64(c.dedicatedMarkWorkersNeeded)
        if c.fractionalUtilizationGoal > 0 {
@@ -566,7 +566,7 @@ func (c *gcControllerState) endCycle() float64 {
        assistDuration := nanotime() - c.markStartTime
 
        // Assume background mark hit its utilization goal.
-       utilization := gcGoalUtilization
+       utilization := gcBackgroundUtilization
        // Add assist utilization; avoid divide by zero.
        if assistDuration > 0 {
                utilization += float64(c.assistTime) / float64(assistDuration*int64(gomaxprocs))
@@ -856,10 +856,16 @@ func gcSetTriggerRatio(triggerRatio float64) {
        }
 }
 
-// gcGoalUtilization is the goal CPU utilization for background
+// gcGoalUtilization is the goal CPU utilization for
 // marking as a fraction of GOMAXPROCS.
 const gcGoalUtilization = 0.25
 
+// gcBackgroundUtilization is the fixed CPU utilization for background
+// marking. It must be <= gcGoalUtilization. The difference between
+// gcGoalUtilization and gcBackgroundUtilization will be made up by
+// mark assists.
+const gcBackgroundUtilization = 0.25
+
 // gcCreditSlack is the amount of scan work credit that can can
 // accumulate locally before updating gcController.scanWork and,
 // optionally, gcController.bgScanCredit. Lower values give a more