Repository navigation
quest: plan a linear parked-group drain in m0 #5453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d3d946b
74fba35
d924070
411667a
dcba6e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # [S] Draining parked groups is near-linear in the backlog | ||
|
|
||
| ## Goal | ||
|
|
||
| Once a subscriber's raised cap releases its parked groups, each delivery | ||
| costs at most O(log P), so draining P parked groups is O(P log P), not | ||
| quadratic. The `origin/resume_overlap` benchmark's per-group drain time no | ||
| longer grows linearly with the parked count. | ||
|
|
||
| ## Plan | ||
|
|
||
| Found on [#5446](https://github.com/moq-dev/moq/pull/5446): 1024 parked groups | ||
| drain at about a tenth of the rate of 64, on `main` as well. | ||
| `track::Subscriber::poll_recv_group` (`rs/moq-net/src/model/track.rs`) runs | ||
| `parked.retain(..)` over every parked group on every poll, re-registering an | ||
| abort waiter on each, so a drain is quadratic. | ||
|
|
||
| Decided 2026-10-13 (maintainer): m0. Groups park in production during a | ||
| same-epoch relay handover: `Copy::wire` (`rs/moq-net/src/model/resume.rs`) | ||
| caps the replaced copy's range, the lite publisher treats that end group as | ||
| a serving cap, and the new route's unbounded demand then drains the parked | ||
| set quadratically. Live players setting no cap of their own doesn't help. | ||
|
|
||
| Recommended: validate lazily. Wake the subscriber from the track (one | ||
| registration) when a cached group aborts, rather than registering on every | ||
| parked group per poll, and on that wake remove exactly the parked entries | ||
| that aborted, cap raised or not. Aborted entries are not a low-end prefix: | ||
| eviction rotates recently read groups to the back and expiry follows last | ||
| access. A sequence can name both a live group and a fetched head, so confirm | ||
| the parked consumer itself aborted before dropping it, and keep any abort | ||
| bookkeeping bounded by what the cache retains, not by lifetime churn. Each removal is paid for by its insertion, and | ||
| the `BTreeMap`'s O(log P) removal is accepted rather than swapping the | ||
| structure. Keep the existing guarantees: a raised `start_at` drops overtaken | ||
| entries, eviction bounds the parked set to what the cache retains, a | ||
| finished track with only aborted parked groups ends, and an abort between | ||
| check and registration still wakes the reader. A track-wide wake fans out to | ||
| every capped subscriber, so extend the benchmark to sweep parked count | ||
| against capped subscribers per track: the parked axis flattens, and a | ||
| per-abort cost that grows with subscribers shows up as a slope. | ||
|
|
||
| Public API: none. Wire: none. | ||
|
|
||
| ## Required | ||
|
|
||
| - [Resume duplicates](/quest/m0/broadcast-epoch/resume-duplicates.md) - reshapes `track::Subscriber`'s delivery record in the same code | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,9 @@ each task's `JoinHandle` the way #5447 did for moq-c sessions, reusing | |
| the `Cancel` its dropped channel produces today. Add a regression per | ||
| binding that injects a panic into one background task and asserts the | ||
| host sees `MOQ_ERROR_PANIC` (moq-c) or the binding's panic error (moq-ffi), | ||
| while another object keeps working. Also add the regression #5447 left out: | ||
| while another object keeps working. A binding's origin task needs its own owner for | ||
| the driver, so its panic can be reported; wrapping the helper that aborts the | ||
| process (`moq_tokio::origin::spawn`) is not enough. Also add the regression #5447 left out: | ||
|
Comment on lines
+25
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Describe
Suggested fix-wrapping the helper that aborts the process (`moq_tokio::origin::spawn`) is not enough.
+wrapping the helper that spawns the driver on the ambient runtime (`moq_tokio::origin::spawn`) is not enough.🤖 Prompt for AI Agents |
||
| a moq-tokio accept loop that panics ends its listener. | ||
|
|
||
| Public API: none expected, beyond the panic error reaching more callbacks. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Qualify the drain targets by subscriber count.
Lines 5-8 state both bounds only as functions of parked groups. The proposed track-wide wake also fans out to every capped subscriber, so its cost depends on subscriber count. State that the bounds hold for a fixed subscriber count and measure the benchmark at each subscriber count.
Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents