Skip to content

ensure timeouts with sub-ms resolution don't occur early and hang#48284

Merged
jkarneges merged 3 commits intomainfrom
jkarneges/timer-fix
Oct 29, 2025
Merged

ensure timeouts with sub-ms resolution don't occur early and hang#48284
jkarneges merged 3 commits intomainfrom
jkarneges/timer-fix

Conversation

@jkarneges
Copy link
Member

@jkarneges jkarneges commented Oct 28, 2025

This corrects the rounding of Duration values in Reactor. Internally, Reactor uses a clock with 10ms "ticks", and when a timer is registered to expire after a given Duration, the value needs to be rounded up to the nearest tick. Currently, before rounding up, as_millis() is called which rounds down to the nearest millisecond. This means that while 11ms correctly rounds to 2 ticks, 10.1ms incorrectly rounds to 1 tick. With the fix, 10.1ms correctly rounds to 2 ticks.

Additionally, Timeout is reworked to panic if a timer notification occurs before enough time has passed. This way, a rounding bug like the one in Reactor can be immediately caught rather than silently result in a timeout never completing.

@jkarneges jkarneges changed the title ensure timeouts with sub-ms resolution don't occur early ensure timeouts with sub-ms resolution don't occur early and hang Oct 28, 2025
@jkarneges jkarneges requested review from a team and removed request for a team October 28, 2025 22:29
@jkarneges jkarneges marked this pull request as draft October 29, 2025 01:46
@jkarneges jkarneges marked this pull request as ready for review October 29, 2025 18:37
@jkarneges jkarneges requested a review from a team October 29, 2025 18:44
@jkarneges jkarneges merged commit 0b5e5c5 into main Oct 29, 2025
19 checks passed
@jkarneges jkarneges deleted the jkarneges/timer-fix branch October 29, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants