Skip to content

bench(net): backport session_fanout_threads to release - #7698

Merged
kixelated merged 1 commit into
releasefrom
backport/fanout-threads-bench
Nov 3, 2026
Merged

kixelated merged 1 commit into
releasefrom
backport/fanout-threads-bench

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Ports main's session_fanout_threads case from moq-dev/moq#7493 onto release, so the pre-cut pairing (just bench origin/release, run from main) can compare #7493's contention fix. This is a bench-only backport under CONTRIBUTING.md's rule (moq-dev/moq#7581). It finishes what moq-dev/moq#7586 left for later. The quest PR is moq-dev/moq#7695.

Changes

On main the case lives in the split session/mod.rs, which doesn't build on release. So it's ported by hand into release's single-file rs/moq-net/benches/session.rs:

  • fanout_threads: main's function, minus the Backend type parameter (release has only the model relay, and Model::PREFIX is ""). Same shape (1 publisher, 64 viewers, 400-byte one-frame groups) and the same case IDs: session_fanout_threads/{moq-lite-06,moq-lite-07-wip}/workers={1,16}.
  • threaded(workers): main's multi-threaded runtime builder.
  • Clock and MeasurementClock: main's round clock, reduced to Wall and Process. release has no SESSION_CPU thread-CPU mode, so the Thread variant is left out. Room gains a clock field, Wall by default, so every other case still times elapsed time exactly as before.
  • Module docs: main's session_fanout_threads paragraph.
  • rs/moq-net/Cargo.toml: tokio's rt-multi-thread dev feature, and libc as a Unix-only dev-dependency, as on main. Cargo.lock gains only moq-net's libc edge.

No shipped code changes. Public API: none. Wire: none.

Notes

  • Merging this touches rs/**, so release-plz will propose a patch bump for moq-net, though only benchmark code changed. I bumped no versions.

Verification

All on release (338cb9b3e8) plus this change, Linux:

  • cargo test --locked -p moq-net --bench session (Criterion's test mode) passes all 318 cases, including the 4 new ones.
  • A short cargo bench run (--warm-up-time 1 --measurement-time 3) of session_fanout_threads measured 1.89 ms (moq-lite-06) and 1.80 ms (moq-lite-07-wip) of process CPU per round at workers=1, against 2.75 ms and 2.55 ms at workers=16. Those are the contention costs perf(moq-net): fanout subscribers stop contending the shared track lock #7493 removes on main.
  • cargo clippy --locked -p moq-net --benches -- -D warnings is clean, with and without --features fuzz. So are cargo fmt --all -- --check, cargo sort --workspace --check, and cargo shear. cargo sort also warns about moq-cli and moq-tokio, but those warnings are already on release, and this PR doesn't touch either file.
  • The case IDs match main's source (rs/moq-net/benches/session/mod.rs, fanout_threads), whose group name is {PREFIX}session_fanout_threads with Model::PREFIX = "", and whose rows are {version}/workers={workers}.

Review

Codex (gpt-6.1-sol, medium effort) ran a local quest review --base origin/release, round 1, on head 283a1bba417ed2173ae24d9b33a57478c86fd0b6. It reported no findings.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Ports main's session_fanout_threads case (#7493) into release's
single-file session bench, under main's case IDs, so the pre-cut pairing
compares the fanout contention fix. Adds a process CPU clock and a
multi-threaded runtime to the bench only; no shipped code changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated added a commit that referenced this pull request Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 3, 2026 07:44

@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: 283a1bb

  • P2 — Keep the multithreaded Tokio feature off wasm (rs/moq-net/Cargo.toml:39–62): The unconditional dev-dependency enables rt-multi-thread for wasm32-unknown-unknown, which Tokio rejects at compile time. This breaks the existing documented cargo test --test wasm -p moq-net --target wasm32-unknown-unknown path. Make that feature a non-wasm target-specific dev-dependency and gate the threaded benchmark as needed.

Backporting the benchmark is a reasonable way to compare releases; target-scoping the runtime feature keeps the change focused. Static review only; I did not run the benchmark or tests.

@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.

Reviewed changes — bench-only backport of main's session_fanout_threads case onto release, hand-ported into release's single-file bench layout; no shipped code, public API, or wire changes.

  • Multi-threaded runtime: threaded(workers) builds a new_multi_thread runtime; rt-multi-thread added to moq-net's tokio dev features.
  • Process-CPU clock: Clock { Wall, Process } and MeasurementClock { Wall, Cpu } ported without main's Thread variant or SESSION_CPU plumbing; Room gains a clock field defaulted to Wall, so every other case still times elapsed time.
  • fanout_threads case: 1 publisher / 64 viewers / 400-byte one-frame groups, registered in criterion_group!, early-returning off Unix and under SESSION_ALLOCS/SESSION_EXPIRY_ONLY.
  • libc: added as a cfg(unix) dev-dependency; Cargo.lock gains only moq-net's edge.

Verified locally: cargo check -p moq-net --bench session --locked is clean, and cargo test -p moq-net --bench session -- --test session_fanout_threads runs all four cases ({moq-lite-06,moq-lite-07-wip}/workers={1,16}), Success, exit 0. The case IDs match main's fanout_threads::<Model> (Model::PREFIX = ""), so the just bench origin/release pairing compares like for like.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@kixelated
kixelated merged commit acf91a0 into release Nov 3, 2026
23 checks passed
@kixelated
kixelated deleted the backport/fanout-threads-bench branch November 3, 2026 16:51
kixelated added a commit to zshenker/moq that referenced this pull request Nov 3, 2026
moq-dev#7695)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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