Skip to content

test: make Waiter futex timed wait test robust on slow CI runners - #591

Merged
lalinsky merged 1 commit into
mainfrom
waiter-timed-wait-test-bound
Jul 19, 2026
Merged

lalinsky merged 1 commit into
mainfrom
waiter-timed-wait-test-bound

Conversation

@lalinsky

Copy link
Copy Markdown
Owner

Problem

common.test.Waiter: futex-based timed wait with timeout failed on macOS CI with TestUnexpectedResult after 221ms. The test does a 50ms futex timed wait and asserts elapsed < 200ms as a sanity check. The Darwin implementation is correct (__ulock_wait gets the timeout in microseconds, maps TIMEDOUT, and the retry loop recomputes the remaining time from the deadline), so the wait fired on time; the thread just wasn't rescheduled for ~170ms afterwards, which is routine on oversubscribed macOS runners. The test predates the recent fs changes and the failure is unrelated to them.

Fix

The upper bound only exists to catch gross timeout miscalculation (wrong units, waiting forever, the realtime-vs-monotonic confusion mentioned in futexTimeout). A 5s bound catches that entire class just as reliably while being immune to scheduler noise; the meaningful assertion is the 40ms lower bound, which is unchanged. Also print the measured elapsed time on failure, so a future trip is diagnosable straight from the CI log.

The 200ms upper bound tripped on a macOS CI runner that took 221ms to
reschedule the thread after a 50ms wait. The bound only exists to catch
gross timeout miscalculation (wrong units, waiting forever), so relax it
to 5s, and print the measured elapsed time on failure so future trips
are diagnosable from the CI log.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd6e0775-7f8b-4bc9-94ef-bdd473eb6bd3

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd48b8 and 1fc4807.

📒 Files selected for processing (1)
  • src/common.zig

📝 Walkthrough

Walkthrough

The futex-based Waiter timed-wait test now logs elapsed time when it fails and allows up to 5000ms for a 50ms wait, accommodating CI scheduling variability.

Changes

Timed wait test

Layer / File(s) Summary
Timed-wait diagnostics and tolerance
src/common.zig
Adds failure-time elapsed-millisecond logging and relaxes the timeout sanity upper bound from 200ms to 5000ms.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • lalinsky/zio#239: Updates the timedWait API while this PR adjusts its timeout test.
  • lalinsky/zio#271: Refactors futex-based timed-wait behavior covered by this test.
  • lalinsky/zio#289: Changes the underlying futex timeout handling tested here.

Poem

Fifty milliseconds, give or take,
CI may nap before it wakes.
If the timer test should complain,
It prints its trail across the lane.
Five seconds keeps the flakes at bay.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: making the Waiter futex timed-wait test more tolerant of slow CI runners.
Description check ✅ Passed The description directly matches the changeset, explaining the timeout tweak and added failure logging.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch waiter-timed-wait-test-bound

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lalinsky
lalinsky merged commit ec7360f into main Jul 19, 2026
27 checks passed
@lalinsky
lalinsky deleted the waiter-timed-wait-test-bound branch July 19, 2026 06:22
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.

1 participant