]> Cypherpunks repositories - gostls13.git/commit
runtime: make bubbled timers more consistent with unbubbled
authorDamien Neil <dneil@google.com>
Mon, 2 Jun 2025 16:26:27 +0000 (09:26 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 4 Jun 2025 16:20:21 +0000 (09:20 -0700)
commit3432c68467d50ffc622fed230a37cd401d82d4bf
tree68e8152e4ba53aef6cb685d95ccc891b14d8c272
parent1aa336209363d9715e145244c7b22620ac0f0584
runtime: make bubbled timers more consistent with unbubbled

This CL makes two changes to reduce the predictability
with which bubbled timers fire.

When asynctimerchan=0 (the default), regular timers with an associated
channel are only added to a timer heap when some channel operation
is blocked on that channel. This allows us to garbage collect
unreferenced, unstopped timers. Timers in a synctest bubble, in
contrast, are always added to the bubble's timer heap.

This CL changes bubbled timers with a channel to be handled the
same as unbubbled ones, adding them to the bubble's timer heap only
when some channel operation is blocked on the timer's channel.
This permits unstopped bubbled timers to be garbage collected,
but more importantly it makes all timers past their deadline
behave identically, regardless of whether they are in a bubble.

This CL also changes timer scheduling to execute bubbled timers
immediately when possible rather than adding them to a heap.
Timers in a bubble's heap are executed when the bubble is idle.
Executing timers immediately avoids creating a predictable
order of execution.

For #73850
Fixes #73934

Change-Id: If82e441546408f780f6af6fb7f6e416d3160295d
Reviewed-on: https://go-review.googlesource.com/c/go/+/678075
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/internal/synctest/synctest_test.go
src/runtime/chan.go
src/runtime/proc.go
src/runtime/select.go
src/runtime/synctest.go
src/runtime/time.go