Skip to content

refactor: finish the ez waiter conversion, and build the poll bridge on kio::Park - #358

Open
kixelated wants to merge 2 commits into
mainfrom
claude/ez-keepalive-waiter
Open

refactor: finish the ez waiter conversion, and build the poll bridge on kio::Park#358
kixelated wants to merge 2 commits into
mainfrom
claude/ez-keepalive-waiter

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Follow-up to #353, now that kio 0.5.3 has shipped. Two independent commits.

ez takes a waiter everywhere

#353 converted ez's poll surface from &Waker to &kio::Waiter, but one method kept a Context: the keep-alive ticker's, which the driver called by building a Context from its waiter. It takes the waiter now, and the Context is built one level down at the only place that genuinely needs one — tokio's Interval::poll_tick.

No behaviour change; the Context is made from the same waker. After this the only Contexts in ez are the AsyncRead/AsyncWrite impls, whose signatures are tokio's.

The poll bridge moves onto kio::Park

kio 0.5.3 released Park — the WaiterCell of moq-dev/moq#2560, renamed — so the hand-rolled retention in Parked goes away. It wraps Park and inherits the reuse Park does: a steady-state cell allocates nothing, where this one built a fresh Waiter and Arc on every poll.

What stays is the release-on-Ready, and deliberately so. Park holds its waiter until the next poll or until it drops — right for a pending operation, wrong for a finished one, where the stream is done with that caller and holding its waker pins the polling task's allocation until something polls the cell again. That was a review finding on #353, so I checked rather than assumed: neutering settle (i.e. using bare Park) fails a_finished_read_releases_the_poller. The two waiters.rs copies still lose ~40% of their lines.

0.5.3 also made Waiter Clone, which retires the two-step dance in the AsyncRead/AsyncWrite impls. They took that shape only because the cell's borrow could not be ended before the &mut self poll; a cloned waiter shares the parked one's identity, so hold hands one out and the borrow ends there.

Still outstanding

AcceptWaiters remains duplicated across the four backends. moq-dev/moq#2604 adds it upstream as kio::Fan; when that releases, those copies collapse to an import. A Park::release() upstream would remove the rest of Parked too — right now reassigning the cell is the only way to drop its waiter.

Verified

Full suites for quinn, quiche, noq and iroh, clippy --all-targets --all-features -D warnings, and cargo fmt --check.

🤖 Generated with Claude Code

(written by Opus 5)

kixelated and others added 2 commits August 2, 2026 17:40
The last poll method in `ez` still taking a `Context` was the keep-alive
ticker's, so the driver built one from its waiter to call it. Take the waiter
instead and build the `Context` at the one place that genuinely needs it, where
tokio's `Interval::poll_tick` demands it.

No behaviour change: the `Context` is made from the same waker, one level down.
Everything else in `ez` already takes `&kio::Waiter`; the only `Context`s left
are the `AsyncRead`/`AsyncWrite` impls, whose signatures are tokio's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
kio 0.5.3 released `Park` (the `WaiterCell` of moq-dev/moq#2560, renamed), so the
hand-rolled retention in `Parked` goes away: it now wraps `Park` and inherits the
reuse `Park` does — a steady-state cell allocates nothing, where this one built a
fresh `Waiter` and `Arc` on every poll.

What stays is the release-on-`Ready`. `Park` holds its waiter until the next poll
or until it drops, which is right for a pending operation but not a finished one:
the stream is done with that caller, and holding its waker pins the polling task's
allocation until something polls the cell again. Neutering `settle` — that is,
using bare `Park` — fails `a_finished_read_releases_the_poller`, so the wrapper
earns its keep.

0.5.3 also made `Waiter` `Clone`, which retires the two-step dance in the
`AsyncRead`/`AsyncWrite` impls. They took that shape only because the cell's
borrow could not be ended before the `&mut self` poll; a cloned waiter shares the
parked one's identity, so `hold` hands one out and the borrow ends there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kixelated, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f44eb4c2-e9cf-4803-8462-f11c894d6bfe

📥 Commits

Reviewing files that changed from the base of the PR and between 346e6db and b0ad230.

📒 Files selected for processing (9)
  • rs/web-transport-iroh/Cargo.toml
  • rs/web-transport-noq/Cargo.toml
  • rs/web-transport-quiche/Cargo.toml
  • rs/web-transport-quiche/src/ez/driver.rs
  • rs/web-transport-quiche/src/ez/recv.rs
  • rs/web-transport-quiche/src/ez/send.rs
  • rs/web-transport-quiche/src/waiters.rs
  • rs/web-transport-quinn/Cargo.toml
  • rs/web-transport-quinn/src/waiters.rs

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0ad2305ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +144
#[derive(Clone, Default)]
pub(crate) struct Parked(Park);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reset parked waiters when cloning sessions

When a Connection is cloned after a poll_* operation has returned Pending, deriving Clone here clones Park and therefore the live waiter identity. If the original handle is then dropped or completes, an otherwise unused clone continues owning its registration, retaining the cancelled task's waker/allocation and causing stale wakeups for potentially the rest of the connection. The previous custom Clone deliberately returned default() because these registrations are per-handle; preserve that behavior here and in the identical Quinn copy at rs/web-transport-quinn/src/waiters.rs, with a regression test for cloning a pending handle.

AGENTS.md reference: AGENTS.md:L46-L47

Useful? React with 👍 / 👎.

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