diff options
| author | Ian Lance Taylor <iant@golang.org> | 2024-10-14 11:46:17 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-10-14 19:04:43 +0000 |
| commit | 48849e0866f64a40d04a9151e44e5a73acdfc17b (patch) | |
| tree | aac98fbc5b93f7a78d2329903a7be7cf6251ebdb /src/time | |
| parent | 1f51b8275826f5793310e4e9032f3d08facc1e27 (diff) | |
| download | go-48849e0866f64a40d04a9151e44e5a73acdfc17b.tar.xz | |
runtime: don't frob isSending for tickers
The Ticker Stop and Reset methods don't report a value,
so we don't need to track whether they are interrupting a send.
This includes a test that used to fail about 2% of the time on
my laptop when run under x/tools/cmd/stress.
Change-Id: Ic6d14b344594149dd3c24b37bbe4e42e83f9a9ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/620136
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/time')
| -rw-r--r-- | src/time/sleep_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go index 5357ed23c8..520ff957d0 100644 --- a/src/time/sleep_test.go +++ b/src/time/sleep_test.go @@ -847,6 +847,31 @@ func testStopResetResultGODEBUG(t *testing.T, testStop bool, godebug string) { wg.Wait() } +// Test having a large number of goroutines wake up a timer simultaneously. +// This used to trigger a crash when run under x/tools/cmd/stress. +func TestMultiWakeup(t *testing.T) { + if testing.Short() { + t.Skip("-short") + } + + goroutines := runtime.GOMAXPROCS(0) + timer := NewTicker(Microsecond) + var wg sync.WaitGroup + wg.Add(goroutines) + for range goroutines { + go func() { + defer wg.Done() + for range 100000 { + select { + case <-timer.C: + case <-After(Millisecond): + } + } + }() + } + wg.Wait() +} + // Benchmark timer latency when the thread that creates the timer is busy with // other work and the timers must be serviced by other threads. // https://golang.org/issue/38860 |
