aboutsummaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2024-01-22 17:50:44 -0500
committerGopher Robot <gobot@golang.org>2024-02-27 19:24:21 +0000
commita6a5c30d2b1338a8445de2499fbe7e9dda103efb (patch)
tree5963ee0235fe8c3e283b1a8a7eb49d871ed4f3f2 /src/time
parent2b72395eadcc46120b27b9689bed84338de5141c (diff)
downloadgo-a6a5c30d2b1338a8445de2499fbe7e9dda103efb.tar.gz
go-a6a5c30d2b1338a8445de2499fbe7e9dda103efb.zip
runtime: disable use of runnext on wasm
When readying a goroutine, the scheduler typically places the readied goroutine in pp.runnext, which will typically be the next goroutine to run in the schedule. In order to prevent a set of ping-pong goroutines from simply switching back and forth via runnext and starving the rest of the run queue, a goroutine scheduled via runnext shares a time slice (pp.schedtick) with the previous goroutine. sysmon detects "long-running goroutines", which really means Ps using the same pp.schedtick for too long, and preempts them to allow the rest of the run queue to run. Thus this avoids starvation via runnext. However, wasm has no threads, and thus no sysmon. Without sysmon to preempt, the possibility for starvation returns. Avoid this by disabling runnext entirely on wasm. This means that readied goroutines always go on the end of the run queue and thus cannot starve via runnext. Note that this CL doesn't do anything about single long-running goroutines. Without sysmon to preempt them, a single goroutine that fails to yield will starve the run queue indefinitely. For #65178. Change-Id: I10859d088776125a2af8c9cd862b6e071da628b5 Cq-Include-Trybots: luci.golang.try:gotip-js-wasm,gotip-wasip1-wasm_wasmtime,gotip-wasip1-wasm_wazero Reviewed-on: https://go-review.googlesource.com/c/go/+/559798 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/time')
-rw-r--r--src/time/sleep_test.go5
1 files changed, 0 insertions, 5 deletions
diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go
index 1ebc2d3c6a..e985870710 100644
--- a/src/time/sleep_test.go
+++ b/src/time/sleep_test.go
@@ -111,11 +111,6 @@ func TestAfterFuncStarvation(t *testing.T) {
// the AfterFunc goroutine instead of the runnable channel goroutine.
// However, in https://go.dev/issue/65178 this was observed to live-lock
// on wasip1/wasm and js/wasm after <10000 runs.
-
- if runtime.GOARCH == "wasm" {
- testenv.SkipFlaky(t, 65178)
- }
-
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
var (