Skip to content

fix(bench): session cells wait out the lite-07 route debounce before the leak check - #9098

Open
kixelated wants to merge 1 commit into
mainfrom
fix/session-bench-retire-linger
Open

kixelated wants to merge 1 commit into
mainfrom
fix/session-bench-retire-linger

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Every lite-07 cell of the moq-net and moq-relay session benches panics in retire with tasks outlived the cell's handles (left 2). This fails Nightly's "Rust bench targets" and "Relay session benchmarks" on main (run 44342367698).

The two tasks are the relay's and the viewer's origin drivers. When a lite-07 session closes, Routed::orphan leaves the claims it served in the origin's route node, so another session can pick them up during the node's debounce (route::relay::debounce, 32 hops of 25 ms). Each orphan holds an origin::Claim, which keeps the origin's driver alive until the node's RouteTimer releases it. Both origins end exactly 800 ms after teardown. That is a bounded linger the route layer intends, not a leak, but retire only yields and never lets protocol time pass.

The relay_session_delivery_credit/moq-lite-07-wip hang in run 44127032469, and the moq-net/auth and moq-relay/auth hangs, were already fixed on main by moq-dev/moq#9039. Bisected locally: it hangs through 2668d1a65b and passes from d9ccbad992, the only moq-net change in that range. Today's Nightly still showed those hangs only because its paired base was cd9a8e9ccf.

Approach

retire pauses the cell's runtime clock, settles, sleeps ROUTE_LINGER (800 ms, which auto-advances instantly), and settles again before asserting that no task is alive. The wait costs no wall time, and the assertion stays exact: a driver still alive past the debounce fails it.

Impact

  • None: bench-only.

Alternatives

  • Release a node's orphans as soon as nothing else owns the origin. The orphan's claim is what keeps the driver running, so the origin can't tell that apart without a new ownership split in the core. It would also only save an 800 ms linger on teardown.
  • Sleep on the wall clock in retire. That adds 800 ms to every cell.

Validation

  • Reproduced on 4f3ba3317f: session_delivery_burst/moq-lite-07-wip/... and session_delivery_credit/moq-lite-07-wip/... panic in retire (left 2). lite-06 passes.
  • Named each spawned driver in the harness: the two survivors are origin 1 (relay) and origin 3 (viewer), and both end with Closed 800 ms after teardown on the wall clock. All session drivers had already ended.
  • Bisected cd9a8e9ccf..4f3ba3317f with that check: first bad is moq-dev/moq#8987.
  • Negative control: with ROUTE_LINGER 1 ms short (799 ms), retire still panics, so the debounce is exactly what the tasks wait on.
  • cargo bench -p moq-net --features fuzz --bench session -- --test: all 448 cells pass. cargo bench -p moq-relay --features test-support --bench session -- --test: all 431 pass.
  • Nightly's quick mode (--quick --warm-up-time 0.05 --measurement-time 0.2) over the relay's 27 credit cells completes, including every lite-07 one.
  • just check passes.

Caused by

  • moq-dev/moq#8987 - had a closed lite-07 session leave its claims in the route node for the debounce, which keeps the origin's driver alive past teardown, but didn't update the session bench's retire check to let that time pass (found by check: Nightly).

Follow-ups

  • Same Nightly job: moq-net/publisher wake/8192 fixture setup costs O(drops × ranges) since moq-dev/moq#8638, and its runtime pushes the job into its 55-minute timeout. Planned separately.
  • "Nightly (Rust benchmark tests)" mesh_sweep::benchmark_route_mesh panics at rs/moq-net/tests/integration/mesh_sweep.rs:790. Out of this PR's scope.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 1aa7818

  • Base: origin/main at 4f3ba33

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1f002-b8a6-7073-8b7c-9687652ba328, round 1

  • Score: 9/10, The narrowly scoped teardown change preserves the leak assertion, with no actionable regressions found by source inspection; builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

…used clock before checking for leaked tasks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 18:55

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound. The leak check stays exact, and the debounce is waited out on a paused clock, so it costs no wall time.

Reviewed changes

  • ROUTE_LINGER constant: 32 × 25 ms, matching route::relay::HOP and MAX_HOPS via debounce.
  • retire waits out the linger: it pauses the clock, settles, sleeps ROUTE_LINGER, and settles again before asserting num_alive_tasks() == 0. tokio::time::pause() is safe here because every call site uses a fresh current_thread runtime with enable_time(), and retire runs once per runtime.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The session benchmark teardown now pauses Tokio time, drains tasks for up to 1,024 yield passes, advances the paused clock through an 800 ms route linger, and performs a second bounded drain before the existing task-count assertion.

Merge Risk: Minimal · up to 1aa78

This change only adjusts benchmark teardown timing to account for the route debounce. It does not affect production behavior, and merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: session bench cells now wait out the lite-07 route debounce before the leak check. The changeset only edits the retire helper in the moq-net session bench, which pause…
Description check Passed The description is closely related to the changeset. It explains the failing lite-07 bench cells, the route debounce cause, the retire change that pauses the clock and sleeps ROUTE_LINGER, the alterna…
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.
Full details: Title check

Explanation

The title names the main change: session bench cells now wait out the lite-07 route debounce before the leak check. The changeset only edits the retire helper in the moq-net session bench, which pauses the clock, sleeps ROUTE_LINGER, and settles before the assertion. The title is specific and accurate, though it is a little long at 83 characters.

Full details: Description check

Explanation

The description is closely related to the changeset. It explains the failing lite-07 bench cells, the route debounce cause, the retire change that pauses the clock and sleeps ROUTE_LINGER, the alternatives considered, and the validation runs. It is detailed and on topic.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc380a1d-8447-4d43-8273-2d325ad447ca
Commits

Reviewing files that changed from the base of the PR and between 4f3ba33 and 1aa7818.

Files selected for processing: 1

  • rs/moq-net/benches/session/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

This branch has not been deployed

No deployments
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