Skip to content

feat(moq-net): share one allocator across a server's sessions - #8926

Merged
kixelated merged 1 commit into
moq-dev:mainfrom
Frando:feat/server-with-allocator
Nov 17, 2026
Merged

kixelated merged 1 commit into
moq-dev:mainfrom
Frando:feat/server-with-allocator

Conversation

@Frando

@Frando Frando commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Problem

A Client can share one bandwidth::Allocator across the sessions it dials (Client::with_allocator), but a Server has no equivalent: every session it accepts starts with Allocator::default(). An application that accepts several sessions can't reserve once and have every session probe for the total, and it can't watch the summed target across them.

The use case is n0-computer/iroh-live#95, encoder rate control. A node hands one allocator to every session it accepts, so an encoder's target bitrate follows the aggregate send rate across its sessions, not a single session's.

Approach

Server::with_allocator mirrors Client::with_allocator: an Option<Allocator> field, the same builder method and a private allocator() that falls back to a fresh registry. The three places that built an accepted session's Allocator::default() (the plain accept, the paused IETF path and the negotiated start) now call server.allocator().

Impact

  • Additive public API: Server::with_allocator. Without it, each accepted session still starts its own empty registry, as before.
  • No behaviour change for existing callers.

Testing

  • New unit test server::tests::an_accepted_session_shares_the_servers_allocator: a reservation taken through the accepted session's Session::allocator moves the target of the allocator the server was given.
  • cargo nextest run -p moq-net --all-features: 4002 passed, the new test and client::tests::a_reconnect_keeps_following_the_reservations among them. Nine heavy sweep and group tests hit the 60s hang limit on a shared machine at load average 16. Rerun on their own, eight pass. The ninth, model::group::test::a_long_compressed_group_sheds_its_front, doesn't touch the server or the allocator.
  • cargo clippy -p moq-net --all-targets --all-features -- -D warnings, cargo fmt --check, cargo doc -p moq-net --all-features with -D warnings, the justfile's cargo sort --check --no-format, and cargo hakari generate --diff (0.9.39) are clean.

Review

Not run: quest isn't installed on this machine, so there was no local quest review round.

Models

Size: XS
Implementer: Claude Code, claude-opus-5-5

🤖 Generated with Claude Code

Server::with_allocator mirrors Client::with_allocator, so the sessions a
server accepts reserve into one registry and each probes for its sum.

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

@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

I reviewed the new Server::with_allocator builder and how it is wired into each accepted session's construction.

  • Server::with_allocator: adds an Option<bandwidth::Allocator> field, a builder, and a private allocator() fallback. It matches Client::with_allocator field for field.
  • Accepted-session wiring: all three places that built an accepted session's bandwidth (Server accept, PausedIetf, NegotiatedStart) now take server.allocator(). No Allocator::default() session sites are left in server.rs.
  • Test and changelog: a unit test checks that a reservation taken through the accepted session moves the given allocator's target. The CHANGELOG.md entry sits under Unreleased.

ℹ️ Session::allocator doc still names only the client

rs/moq-net/src/session.rs:273-275 says a session's registry is "a Client::with_allocator allocator's when the session was dialed with one". An accepted session can now share one too, so it would help to also link Server::with_allocator there. This doesn't block the merge.

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

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Server now accepts an optional shared bandwidth allocator. Accepted lite, IETF, and negotiated lite sessions use the configured allocator, or a default allocator when none is configured. A test checks that an accepted IETF session’s reservation is reflected in the server allocator target. The Unreleased changelog documents the new method and behavior.

Merge Risk: Minimal · up to d49f0

This adds an optional way to share one bandwidth allocator across a server's accepted sessions. Behavior is unchanged when it isn't configured. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Server gains a shared bandwidth allocator so one allocator is used across a server's accepted sessions. It follows the conventional commit format and matches the objec…
Description check Passed The description states the problem (Server lacks a with_allocator equivalent to Client::with_allocator), the approach (an Option field, a builder method, and a fallback allocator() used in …
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: Server gains a shared bandwidth allocator so one allocator is used across a server's accepted sessions. It follows the conventional commit format and matches the objectives, which add Server::with_allocator. It is 61 characters and specific.

Full details: Description check

Explanation

The description states the problem (Server lacks a with_allocator equivalent to Client::with_allocator), the approach (an Option<Allocator> field, a builder method, and a fallback allocator() used in three accept paths), the impact (additive API, no behaviour change for existing callers), and the testing performed. It is directly related to the changeset.

Finishing Touches

Simplify code

  • 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: 6b47dec5-2304-437d-a8a7-abe6c9bfdec8
Commits

Reviewing files that changed from the base of the PR and between 6488ce6 and d49f088.

Files selected for processing: 2

  • rs/moq-net/CHANGELOG.md
  • rs/moq-net/src/server.rs

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

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator

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: d49f0885912507e7914945bfccfc66c0d3ca0dda.

No actionable issue found. All three accept paths use the same supplied registry; the default still creates a fresh one per session. This makes the reservation target common to sessions whose transports support probing. It does not combine their measured send rates: each session still binds its allocator handle to its own estimate. That distinction fits the intended encoder integration, which can supply its own estimate to the node-level allocator.

The new test checks that an accepted session's reservation reaches the supplied registry. A second accepted session would make the shared-registry invariant explicit, but I wouldn't block on it. Static review only; I did not run tests or reproduce the reported suite timeouts. COMMENT only, not approval.

@kixelated
kixelated added this pull request to the merge queue Nov 17, 2026
Merged via the queue into moq-dev:main with commit 31ddf9b Nov 17, 2026
5 checks passed
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.

2 participants