@@ -290,7 +290,7 @@ func (c *gcControllerState) init(gcPercent int32) {
290
290
// startCycle resets the GC controller's state and computes estimates
291
291
// for a new GC cycle. The caller must hold worldsema and the world
292
292
// must be stopped.
293
- func (c * gcControllerState ) startCycle (markStartTime int64 ) {
293
+ func (c * gcControllerState ) startCycle (markStartTime int64 , procs int ) {
294
294
c .scanWork = 0
295
295
c .bgScanCredit = 0
296
296
c .assistTime = 0
@@ -316,7 +316,7 @@ func (c *gcControllerState) startCycle(markStartTime int64) {
316
316
// dedicated workers so that the utilization is closest to
317
317
// 25%. For small GOMAXPROCS, this would introduce too much
318
318
// error, so we add fractional workers in that case.
319
- totalUtilizationGoal := float64 (gomaxprocs ) * gcBackgroundUtilization
319
+ totalUtilizationGoal := float64 (procs ) * gcBackgroundUtilization
320
320
c .dedicatedMarkWorkersNeeded = int64 (totalUtilizationGoal + 0.5 )
321
321
utilError := float64 (c .dedicatedMarkWorkersNeeded )/ totalUtilizationGoal - 1
322
322
const maxUtilError = 0.3
@@ -329,14 +329,14 @@ func (c *gcControllerState) startCycle(markStartTime int64) {
329
329
// Too many dedicated workers.
330
330
c .dedicatedMarkWorkersNeeded --
331
331
}
332
- c .fractionalUtilizationGoal = (totalUtilizationGoal - float64 (c .dedicatedMarkWorkersNeeded )) / float64 (gomaxprocs )
332
+ c .fractionalUtilizationGoal = (totalUtilizationGoal - float64 (c .dedicatedMarkWorkersNeeded )) / float64 (procs )
333
333
} else {
334
334
c .fractionalUtilizationGoal = 0
335
335
}
336
336
337
337
// In STW mode, we just want dedicated workers.
338
338
if debug .gcstoptheworld > 0 {
339
- c .dedicatedMarkWorkersNeeded = int64 (gomaxprocs )
339
+ c .dedicatedMarkWorkersNeeded = int64 (procs )
340
340
c .fractionalUtilizationGoal = 0
341
341
}
342
342
@@ -464,7 +464,7 @@ func (c *gcControllerState) revise() {
464
464
// endCycle computes the trigger ratio for the next cycle.
465
465
// userForced indicates whether the current GC cycle was forced
466
466
// by the application.
467
- func (c * gcControllerState ) endCycle (userForced bool ) float64 {
467
+ func (c * gcControllerState ) endCycle (now int64 , procs int , userForced bool ) float64 {
468
468
// Record last heap goal for the scavenger.
469
469
// We'll be updating the heap goal soon.
470
470
gcController .lastHeapGoal = gcController .heapGoal
@@ -495,13 +495,13 @@ func (c *gcControllerState) endCycle(userForced bool) float64 {
495
495
// heap growth is the error.
496
496
goalGrowthRatio := c .effectiveGrowthRatio ()
497
497
actualGrowthRatio := float64 (c .heapLive )/ float64 (c .heapMarked ) - 1
498
- assistDuration := nanotime () - c .markStartTime
498
+ assistDuration := now - c .markStartTime
499
499
500
500
// Assume background mark hit its utilization goal.
501
501
utilization := gcBackgroundUtilization
502
502
// Add assist utilization; avoid divide by zero.
503
503
if assistDuration > 0 {
504
- utilization += float64 (c .assistTime ) / float64 (assistDuration * int64 (gomaxprocs ))
504
+ utilization += float64 (c .assistTime ) / float64 (assistDuration * int64 (procs ))
505
505
}
506
506
507
507
triggerError := goalGrowthRatio - c .triggerRatio - utilization / gcGoalUtilization * (actualGrowthRatio - c .triggerRatio )
0 commit comments