Skip to content

Commit 2792348

Browse files
committed
runtime: separate GC background utilization from goal utilization
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rick Hudson <[email protected]>
1 parent 504a305 commit 2792348

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/runtime/mgc.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ const (
299299

300300
// gcMarkWorkerFractionalMode indicates that a P is currently
301301
// running the "fractional" mark worker. The fractional worker
302-
// is necessary when GOMAXPROCS*gcGoalUtilization is not an
303-
// integer. The fractional worker should run until it is
302+
// is necessary when GOMAXPROCS*gcBackgroundUtilization is not
303+
// an integer. The fractional worker should run until it is
304304
// preempted and will be scheduled to pick up the fractional
305-
// part of GOMAXPROCS*gcGoalUtilization.
305+
// part of GOMAXPROCS*gcBackgroundUtilization.
306306
gcMarkWorkerFractionalMode
307307

308308
// gcMarkWorkerIdleMode indicates that a P is running the mark
@@ -453,9 +453,9 @@ func (c *gcControllerState) startCycle() {
453453
memstats.next_gc = memstats.heap_live + 1024*1024
454454
}
455455

456-
// Compute the total mark utilization goal and divide it among
456+
// Compute the background mark utilization goal and divide it among
457457
// dedicated and fractional workers.
458-
totalUtilizationGoal := float64(gomaxprocs) * gcGoalUtilization
458+
totalUtilizationGoal := float64(gomaxprocs) * gcBackgroundUtilization
459459
c.dedicatedMarkWorkersNeeded = int64(totalUtilizationGoal)
460460
c.fractionalUtilizationGoal = totalUtilizationGoal - float64(c.dedicatedMarkWorkersNeeded)
461461
if c.fractionalUtilizationGoal > 0 {
@@ -566,7 +566,7 @@ func (c *gcControllerState) endCycle() float64 {
566566
assistDuration := nanotime() - c.markStartTime
567567

568568
// Assume background mark hit its utilization goal.
569-
utilization := gcGoalUtilization
569+
utilization := gcBackgroundUtilization
570570
// Add assist utilization; avoid divide by zero.
571571
if assistDuration > 0 {
572572
utilization += float64(c.assistTime) / float64(assistDuration*int64(gomaxprocs))
@@ -856,10 +856,16 @@ func gcSetTriggerRatio(triggerRatio float64) {
856856
}
857857
}
858858

859-
// gcGoalUtilization is the goal CPU utilization for background
859+
// gcGoalUtilization is the goal CPU utilization for
860860
// marking as a fraction of GOMAXPROCS.
861861
const gcGoalUtilization = 0.25
862862

863+
// gcBackgroundUtilization is the fixed CPU utilization for background
864+
// marking. It must be <= gcGoalUtilization. The difference between
865+
// gcGoalUtilization and gcBackgroundUtilization will be made up by
866+
// mark assists.
867+
const gcBackgroundUtilization = 0.25
868+
863869
// gcCreditSlack is the amount of scan work credit that can can
864870
// accumulate locally before updating gcController.scanWork and,
865871
// optionally, gcController.bgScanCredit. Lower values give a more

0 commit comments

Comments
 (0)