Skip to content

Commit b783930

Browse files
committed
runtime: simplify fractional mark worker scheduler
We haven't used non-zero gcForcePreemptNS for ages. Remove it and declutter the code. Change-Id: Id5cc62f526d21ca394d2b6ca17d34a72959535da Reviewed-on: https://go-review.googlesource.com/68572 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rick Hudson <[email protected]>
1 parent 315c28b commit b783930

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/runtime/mgc.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -711,22 +711,6 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
711711
// This P has picked the token for the fractional worker.
712712
// Is the GC currently under or at the utilization goal?
713713
// If so, do more work.
714-
//
715-
// We used to check whether doing one time slice of work
716-
// would remain under the utilization goal, but that has the
717-
// effect of delaying work until the mutator has run for
718-
// enough time slices to pay for the work. During those time
719-
// slices, write barriers are enabled, so the mutator is running slower.
720-
// Now instead we do the work whenever we're under or at the
721-
// utilization work and pay for it by letting the mutator run later.
722-
// This doesn't change the overall utilization averages, but it
723-
// front loads the GC work so that the GC finishes earlier and
724-
// write barriers can be turned off sooner, effectively giving
725-
// the mutator a faster machine.
726-
//
727-
// The old, slower behavior can be restored by setting
728-
// gcForcePreemptNS = forcePreemptNS.
729-
const gcForcePreemptNS = 0
730714

731715
// TODO(austin): We could fast path this and basically
732716
// eliminate contention on c.fractionalMarkWorkersNeeded by
@@ -739,10 +723,8 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
739723
// TODO(austin): Shorter preemption interval for mark
740724
// worker to improve fairness and give this
741725
// finer-grained control over schedule?
742-
now := nanotime() - gcController.markStartTime
743-
then := now + gcForcePreemptNS
744-
timeUsed := c.fractionalMarkTime + gcForcePreemptNS
745-
if then > 0 && float64(timeUsed)/float64(then) > c.fractionalUtilizationGoal {
726+
delta := nanotime() - c.markStartTime
727+
if delta > 0 && float64(c.fractionalMarkTime)/float64(delta) > c.fractionalUtilizationGoal {
746728
// Nope, we'd overshoot the utilization goal
747729
atomic.Xaddint64(&c.fractionalMarkWorkersNeeded, +1)
748730
return nil

0 commit comments

Comments
 (0)