Skip to content

fix(net): backport stop idle viewer sessions from waking every 100ms (#5382) - #5384

Merged
kixelated merged 1 commit into
releasefrom
backport/idle-session-wakes
Oct 13, 2026
Merged

kixelated merged 1 commit into
releasefrom
backport/idle-session-wakes

Conversation

@kixelated

@kixelated kixelated commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Backport of #5382 to release: an idle viewer session no longer wakes its server every 100ms.

  • Root cause: the Session handle held its own send-bandwidth consumer, so the sampler never idled, and each open PROBE stream ticked every 100ms reading the transport stats. An idle viewer cost its server ~40 driver polls and ~20 path-stats reads per second.
  • Fix: the handle keeps a bandwidth::Weak, so only consumers a caller holds count as demand. PROBE serving follows the supervisor's (send rate, rtt) estimate instead of a timer: while a PROBE stream is open, the supervisor samples on driver polls that already happen (at most once per 100ms), and ProbeServe wakes on a change or its age deadline. Reporting rules (thresholds, decay, 10s max age) are unchanged.
  • Differs from fix(net): stop idle viewer sessions from waking every 100ms #5382 only where release lacks main's types: runtime::Deadline on the tokio clock, no Handles struct (the estimate is a Session::new argument), and tests on tokio::test(start_paused = true) instead of moq_net_sim. Also drops the now-unused Deadline::at. The session_idle bench is not ported.
  • Regression test tests/idle_session.rs fails without the fix on release (1200 stats reads over 60s; with it, at most 6).

API and wire impact

None. Session::send_bandwidth() mints a fresh consumer per call; PROBE carries the same messages under the same rules.

Checks

  • Tested head 0a3ec82b4 against origin/release 1c651615b: just check origin/release passes (5083 + 387 + 132 + 78 tests).

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…5382)

The Session handle held its own send-bandwidth consumer, so the sampler
never idled, and each open PROBE stream ticked every 100ms reading the
transport stats. Together an idle viewer cost its server ~40 driver polls
and ~20 path-stats reads per second.

The handle now keeps a weak reference, so only held consumers are demand.
PROBE serving follows the supervisor's estimate instead of a timer: the
supervisor samples on driver polls that already happen (at most once per
100ms) while a PROBE stream is open, and ProbeServe wakes on a change or
its age deadline. Reporting rules (thresholds, decay, max age) are
unchanged. An idle viewer now costs one max-age refresh per 10s.

Ported by hand onto release's tokio-clock runtime and test harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T01:58:59.595144Z 0a3ec82 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: 0a3ec82.

No actionable defects found in the full backport diff and relevant surrounding code. The direction is sound: the session handle no longer creates sampling demand, and PROBE uses estimate changes plus age deadlines. I checked the release-specific Deadline/Clock behavior, Lite versus IETF Session::new wiring, and consumer drop/recreation semantics.

Verification limits: GitHub-only static review; I did not run tests or benchmarks. Passive sampling still relies on driver activity or the max-age deadline, so this does not establish prompt reporting of transport-only changes.

(Written by OpenAI)

@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: 0a3ec82b49

ℹ️ 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".

.expect("server handshake failed");
tokio::spawn(run(driver));
session
(session, spawn_counted(driver))

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 Keep poll counting out of shared benchmark sessions

Because rs/moq-net/benches/session.rs imports this harness and constructs every relay, publisher, and viewer connection through connect_mock, wrapping every server driver here adds an atomic increment to the timed delivery and join paths even though those benchmarks never read the counter. The overhead scales with session count and poll activity, contaminating the benchmark slopes used to evaluate this optimization; make counting opt-in for idle_session and retain the uninstrumented runner by default.

AGENTS.md reference: AGENTS.md:L52-L52

Useful? React with 👍 / 👎.

Comment on lines +46 to +47
#[tokio::test(start_paused = true)]
async fn idle_viewer_does_not_wake_the_server() {

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 Add an idle-session fan-out benchmark

This one-viewer regression test verifies wake and stats-read counts, but it does not measure the CPU cost or sweep the publisher/viewer session axes that motivated the change. The existing benches/session.rs cases exercise active delivery and joins rather than elapsed idle PROBE behavior, so a future per-session regression would not appear as a measured slope; add an idle benchmark across multiple publisher and viewer counts.

AGENTS.md reference: AGENTS.md:L35-L36

Useful? React with 👍 / 👎.

@kixelated
kixelated merged commit f1a1deb into release Oct 13, 2026
7 checks passed
@kixelated
kixelated deleted the backport/idle-session-wakes branch October 13, 2026 04:42
@moq-bot moq-bot Bot mentioned this pull request Oct 13, 2026
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