]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: ready scavenger without next
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 22 Nov 2019 21:06:15 +0000 (21:06 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 27 Nov 2019 23:14:19 +0000 (23:14 +0000)
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 <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgcscavenge.go
src/runtime/proc_test.go

index 9c45ce8c87aa83176c0c0e8c43eaa11798282331..c7bab59fb7d697e9d80fd98d2c7f81d33fe1c57b 100644 (file)
@@ -166,9 +166,15 @@ func wakeScavenger() {
                stopTimer(scavenge.timer)
 
                // Unpark the goroutine and tell it that there may have been a pacing
-               // change.
+               // change. Note that we skip the scheduler's runnext slot because we
+               // want to avoid having the scavenger interfere with the fair
+               // scheduling of user goroutines. In effect, this schedules the
+               // scavenger at a "lower priority" but that's OK because it'll
+               // catch up on the work it missed when it does get scheduled.
                scavenge.parked = false
-               goready(scavenge.g, 0)
+               systemstack(func() {
+                       ready(scavenge.g, 0, false)
+               })
        }
        unlock(&scavenge.lock)
 }
index 48b865e8a516206d289ca0610fe906f6910b7370..acee7a181936ce1fd38d5247a55b0673d8dacaaa 100644 (file)
@@ -6,7 +6,6 @@ package runtime_test
 
 import (
        "fmt"
-       "internal/testenv"
        "math"
        "net"
        "runtime"
@@ -423,7 +422,6 @@ func TestPingPongHog(t *testing.T) {
        if testing.Short() {
                t.Skip("skipping in -short mode")
        }
-       testenv.SkipFlaky(t, 35271)
 
        defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
        done := make(chan bool)