Skip to content

Commit 8a5af79

Browse files
committed
runtime: ready scavenger without next
This change makes it so that waking up the scavenger readies its goroutine without "next" set, so that it doesn't interfere with the application's use of the runnext feature in the scheduler which helps fairness. As of CL 201763 the scavenger began waking up much more often, and in TestPingPongHog this meant that it would sometimes supercede either a hog or light goroutine in runnext, leading to a skew in the results and ultimately a test flake. This change thus re-enables the TestPingPongHog test on the builders. Fixes #35271. Change-Id: Iace08576912e8940554dd7de6447e458ad0d201d Reviewed-on: https://go-review.googlesource.com/c/go/+/208380 Run-TryBot: Michael Knyszek <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 9174e2c commit 8a5af79

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/runtime/mgcscavenge.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,15 @@ func wakeScavenger() {
166166
stopTimer(scavenge.timer)
167167

168168
// Unpark the goroutine and tell it that there may have been a pacing
169-
// change.
169+
// change. Note that we skip the scheduler's runnext slot because we
170+
// want to avoid having the scavenger interfere with the fair
171+
// scheduling of user goroutines. In effect, this schedules the
172+
// scavenger at a "lower priority" but that's OK because it'll
173+
// catch up on the work it missed when it does get scheduled.
170174
scavenge.parked = false
171-
goready(scavenge.g, 0)
175+
systemstack(func() {
176+
ready(scavenge.g, 0, false)
177+
})
172178
}
173179
unlock(&scavenge.lock)
174180
}

src/runtime/proc_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package runtime_test
66

77
import (
88
"fmt"
9-
"internal/testenv"
109
"math"
1110
"net"
1211
"runtime"
@@ -423,7 +422,6 @@ func TestPingPongHog(t *testing.T) {
423422
if testing.Short() {
424423
t.Skip("skipping in -short mode")
425424
}
426-
testenv.SkipFlaky(t, 35271)
427425

428426
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
429427
done := make(chan bool)

0 commit comments

Comments
 (0)