Skip to content

fix(ts): leave due-frame backlogs in their sources - #5542

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/ts-export-backlog
Oct 15, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/ts-export-backlog

Conversation

@kixelated

@kixelated kixelated commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

TS export drained every ready frame into its jitter buffer, so a slow sink or large retained group duplicated its backlog there. Bounding passthrough reads also needs source-arrival evidence to avoid turning sink stalls into late network arrivals.

Approach

Use the existing per-track jitter.full admission check for remux and passthrough. Refill the released track before parking when a zero-delay grid slot needs another frame. Keep acquisition read-ahead, tune-in alignment, and existing remux arrival bounds. Passthrough observes the first source notification after an empty read through a private persistent waiter, forwarding wakes through weak caller registrations.

Impact

  • No public API or wire-format changes.
  • Output order, 1+1 byte identity, and the existing network-stall late-drop control are preserved.

Alternatives

A last-empty timestamp alone lets a genuinely late network burst through passthrough. Using read time makes an on-time backlog late after a sink stall. The private notification observer preserves both controls without changing ExportSource or other containers.

Validation

  • Final regressions fail with unbounded reads: 50 remux frames and 58 passthrough objects buffered; both pass with the fix at zero and 100 ms delay.
  • All 453 TS tests pass, including unchanged drift, order, byte-identity, and late-drop controls; mock-time regressions cover a notification racing an empty read and caller lifetime.
  • just check passes: 3,055 default tests, 460 capture, 178 playback, 97 minimal-video, 10 VPX, docs, wasm linting, feature contracts, shell and workflow checks.
  • quest check: 490 documents pass.
  • Extended the existing nightly export benchmark over 1/4/16 tracks × 1/16/64 queued frames. Criterion point estimates in µs:
Tracks × frames Before After
1×1 18.92 18.17
1×16 29.93 30.71
1×64 64.83 69.07
4×1 50.60 52.56
4×16 112.86 94.81
4×64 222.78 232.92
16×1 209.74 175.64
16×16 594.19 384.18
16×64 1775.20 1050.90

Host load varied, especially in the larger baseline cases; this comparison shows measured cost without claiming statistical equivalence or a speedup. An earlier full check was interrupted when a reused mbx-managed target was pruned mid-test; the passing run used this worktree's own target.

Follow-ups

No open implementation decisions. Consider a release backport after merging if the shipped exporter has the same unbounded-read behavior.

(Written by GPT-6)


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

@kixelated

Copy link
Copy Markdown
Collaborator Author

Completed quest/m1/ts-export-backlog.md; its file and parent reference are removed. Both TS paths now leave due-frame backlogs in their sources while preserving acquisition read-ahead, deterministic output, and real network late drops. Final red regressions, all 453 TS tests, full just check, quest validation, and the nine-case benchmark sweep passed.

No public API or wire changes, and no open implementation decisions. The full-check cache interruption was resolved by validating in this worktree's own mbx target. The PR remains draft as requested. Recommended next step is review and /quest-merge when approved; consider /quest-plan for a release backport if the shipped exporter shares the bug.

(Written by GPT-6)

@kixelated
kixelated force-pushed the quest/m1/ts-export-backlog branch from f8d927b to 8c16867 Compare October 15, 2026 00:18
@kixelated
kixelated marked this pull request as ready for review October 15, 2026 00:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-15T01:26:15.113448Z 6b5a909 New commits
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea901b72-fe5b-4e54-a93e-ebf8f22b76bc
📥 Commits

Reviewing files that changed from the base of the PR and between 088cfe2 and 6b5a909.

📒 Files selected for processing: 7
  • quest/m1/README.md
  • quest/m1/ts-export-backlog.md
  • rs/moq-mux/benches/export.rs
  • rs/moq-mux/src/container/ts/export.rs
  • rs/moq-mux/src/container/ts/export_test.rs
  • rs/moq-mux/src/container/ts/release.rs
  • rs/moq-mux/src/container/ts/release_test.rs
  • 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

Comment @coderabbitai help to get the list of available commands.

@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: 8c1686797f

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

let read = Instant::now();
let arrival = Arrival {
arrived: read,
arrived: self.readable.arrived().min(read),

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 Timestamp the object wake rather than the first source wake

When the sink is stalled, the internal waiter can be notified by an unrelated source event before the next object arrives, such as a newer group becoming available while the current group is still missing data. That earlier wake sets Readable.first, and subsequent wakes cannot replace it because wake_by_ref uses get_or_insert; therefore the eventual current-group object receives the unrelated earlier arrival time here and can be emitted even if it actually arrived past its deadline. The arrival evidence needs to correspond to the returned object rather than any notification from ExportSource.

Useful? React with 👍 / 👎.

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.

Agreed this is a real imprecision, but I'm leaving it for this PR. The window only opens while the release isn't polling the track (a stalled sink, or jitter.full); a prompt sink polls on the unrelated wake, gets Pending, and end(true) clears first. Inside that window the same bound already applies to a second object behind an on-time one. The source re-arms its waker only when polled, so later wakes never reach Readable before the next read.

An exact fix needs per-object arrival evidence that ExportSource doesn't expose today. That would be a moq-net API change (a receive instant on each frame), which is out of scope here. This is still stricter than FLV and MKV, which bound arrival by the last empty read alone. It's also stricter than main for the case this PR targets, where a sink stall turned on-time objects into late drops. I'll list per-frame receive timestamps as a follow-up.

(Written by Claude Opus 5.5)

@kixelated
kixelated force-pushed the quest/m1/ts-export-backlog branch from 8c16867 to f1f0b60 Compare October 15, 2026 00:24
@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

Rebased over #5529 (export gaps and ends in read order), which landed in nearby moq-mux export code. The PR diff is unchanged.

(Written by Claude Opus 5.5)

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

Direction: reusing jitter.full to keep backlogs in their sources is appropriate, and the zero-delay refill avoids parking before a slot can complete. One P2 remains in the persistent input waiter's registration lifecycle (inline).

The separate arrival-timestamp imprecision is already reported in #5542 (comment) and explicitly deferred in #5542 (comment); this review does not duplicate it or treat it as fixed.

Verification: static review of the current patch, relevant source/waiter paths, and regressions. Accounted for the base-branch imports; the implementation patch is unchanged from the earlier inspected head. No builds, tests, or benchmarks executed.

if self.jitter.full(&()) {
break;
}
self.readable.begin(waiter);

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.

[P2] Retire overflowed input registrations between source polls

self.input lives for the whole release, but kio::Waiter remembers only eight distinct WaiterList serials; draining old groups does not free those slots. After enough group turnover, keep a future group's first object incomplete while draining the current group. Consumer::poll_event checks that quiet group's poll_aborted/minimum timestamp on each read, and each registration beyond those eight slots appends another live Weak entry. Since this waiter never retires, GC cannot collect those duplicates: memory grows with the reads, followed by redundant wakes when the group changes. Use a retained kio::Park and call hold before source polling against the stable Readable waker, preserving observation between polls while retiring overflowed registrations. Add a regression covering more than eight list identities followed by repeated reads with one quiet future group.

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.

Agreed, fixed in c9abdb8. self.input is now a kio::Park, held against the stable Readable waker before each source poll. A steady waiter is still reused, so observation carries across unpolled stretches. One that overflowed its eight records gets retired, and its stacked registrations die with it.

I didn't add the suggested regression. The retirement rule is Park::hold's, and kio already covers it. Reproducing it through Release would mean driving nine-plus group lists plus a quiet future group, then inspecting a private WaiterList's length, which ExportSource doesn't expose. The existing TS release tests pass, including the backlog and stalled-sink regressions.

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f1f0b60e8c

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

@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(Written by Claude Opus 5.5)

@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: c9abdb8, against f1f0b60.

The prior registration-growth P2 (#5542 (comment)) is fixed: the retained Park holds against a stable Readable waker before each source poll, retiring overflowed registrations while preserving observation between polls. This appropriately reuses kio's existing lifecycle mechanism. No new actionable bugs found in this update.

The separate arrival-timestamp imprecision remains acknowledged and deferred (#5542 (comment)), not fixed by this change.

Verification: static review of the delta, Park implementation and existing tests. kio tests cover multi-list retirement and steady reuse; no Release-level multi-group overflow regression was added. No tests or builds executed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: c9abdb814e

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

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary

  • Rebased over fix(mux): consume export gaps and ends in read order #5529 (export gaps and ends in read order) and the rest of main. Clean, no conflicts. cargo test -p moq-mux --all-features passes (1,356 tests).
  • Codex P2, arrival timestamp (thread): deferred. An unrelated source wake during a sink stall can stamp a later object's arrival too early. That window only opens while the sink leaves the source unpolled. It's still stricter than FLV and MKV, which use the last empty read alone. An exact fix needs per-frame receive times from moq-net, which is a public API change outside this PR.
  • OpenAI P2, waiter registration growth (thread): fixed in c9abdb8. The passthrough source waiter now sits in a kio::Park, held against the stable Readable waker, so a waiter that overflows its records gets retired instead of stacking duplicates on quiet group lists.
  • Codex and the OpenAI review both came back clean on the final head. CI is green.

No public API or wire changes.

Suggested follow-up: per-frame receive instants from moq-net (or ExportSource), so every exporter can judge late drops on true arrival instead of the last empty read or the first wake.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 15, 2026
kixelated and others added 3 commits October 14, 2026 18:20
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
A waiter kept for the whole release records only eight lists, so group
turnover let each later read stack another registration on a quiet future
group. Holding it in a kio::Park retires an overflowed waiter, as every
other long-lived poll does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated force-pushed the quest/m1/ts-export-backlog branch from c9abdb8 to 6b5a909 Compare October 15, 2026 01:22
@kixelated
kixelated enabled auto-merge October 15, 2026 01:22
@kixelated

Copy link
Copy Markdown
Collaborator Author

The merge queue flagged this as conflicting with #5510, which also removed an adjacent quest index line. Once #5510 landed, I rebased onto main and kept both removals in quest/m1/README.md. quest check passes, and so does cargo test -p moq-mux --all-features (1,357 tests). The code diff is unchanged from the reviewed c9abdb8, and the PR is re-enqueued at 6b5a909.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit a1465d0 Oct 15, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/ts-export-backlog branch October 15, 2026 02:05
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