Repository navigation
kj-rs-tokio: Test that a zero timeout doesn't park, not how long it takes - #8568
Conversation
There was a problem hiding this comment.
Superseded by the review of
9ad476c8.
This review, of fede11a2
✅ Approved — This pull request replaces a flaky timing check with a park count that checks the behaviour directly. I found no issues in the code or the docs.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
The park counter is incremented once per block_on in wait_*, so it counts exactly what the tests mean to rule out. The C++ and Rust tests each check one half of the fix.
📝 Documentation: ✅ LGTM
The doc comments on park_count and on the new tests describe what the code does now.
Reviewed commit: fede11a2
…akes "an already-due timer fires without waiting for a tokio tick" required the median of nine zero-delay timer waits to be under 1 ms. A due timer doesn't sleep, but the wait still costs a TokioPort::poll(), whose 16 yields to tokio take about 0.4 ms on an M5 Pro and about 1.3 ms on CI's macOS runners: more than the 1 ms tick the test means to rule out. Every run on CI's macOS runners failed it, and with every core busy it failed 5 to 8 runs in 30 locally. Replace it with a Rust unit test of the fix it guarded, wait_timeout_ns(0) polling instead of parking: a task spawned before the call runs during it either way, and records whether the port was parked (SharedState::in_wait). It fails if the zero-timeout check is removed. The C++ side needs no test of its own: TokioEventPort::wait() passes on the zero timeout that kj::TimerImpl::timeoutToNextEvent() returns for a due timer.
fede11a to
9ad476c
Compare
There was a problem hiding this comment.
✅ Approved — The new test checks the zero-timeout behaviour directly instead of timing it, and the flaky timing test is removed. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
The test reads in_wait from a task that runs inside the call, so it tells polling apart from parking without depending on timing. It fails if the zero-timeout early return in wait_timeout_ns is removed.
📝 Documentation: ✅ LGTM
The doc comment on zero_timeout_does_not_park describes the current behaviour and why it matters (tokio's 1 ms tick rounding).
Reviewed commit: 9ad476c8
an already-due timer fires without waiting for a tokio tick(added in #8476) required the median of nine zero-delay timer waits to be under 1 ms. A due timer doesn't sleep, but the wait still costs aTokioPort::poll(), whose 16 yields to tokio take about 0.4 ms on an M5 Pro and about 1.3 ms on CI's macOS runners: more than the 1 ms tick the test means to rule out. Every run on CI's macOS runners fails it once something forces the test to re-run (e.g. #8248), and with every core busy it fails 5 to 8 runs in 30 locally onmain.This replaces it with a Rust unit test of the fix it guarded,
wait_timeout_ns(0)polling instead of parking. A task spawned before the call runs during it either way, and records whether the port was parked (SharedState::in_wait). The test fails if the zero-timeout check is removed. The C++ side needs no test of its own:TokioEventPort::wait()passes on the zero timeout thatkj::TimerImpl::timeoutToNextEvent()returns for a due timer.Separately, the cost of
poll()means asetTimeout(fn, 0)still takes about 0.4 ms locally and over 1 ms on CI's macOS runners; withPOLL_YIELD_BUDGETat 1 it takes about 20 µs. That's not addressed here.