Skip to content

quest(m1): plan PSI pacing within the system buffers - #5304

Merged
kixelated merged 2 commits into
mainfrom
quest/m1/tstd/psi-runs
Oct 13, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m1/tstd/psi-runs

Conversation

@kixelated

@kixelated kixelated commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

This PR originally suppressed adjacent identical PAT/PMT runs so aligned keyframes on several video PIDs would not overflow the 512 B TBsys. #5306 rewrites the same layout code: its padded planner places tables, nulls and media at absolute packet positions, paces TBsys (shared by the PAT and PMT), and already passes this PR's 3/4/8-PID regression with every tune-in copy kept. Suppression would only reach unpadded output, which has no mux rate and makes no system-buffer claim. Bsys, PID 1-3 passthrough, and a compliance.py grade are still missing.

Approach

The suppression commits stay in this PR's history (last head 1672a5e518fc2918535cde5cb39f0da399553823). The branch is reset to main and now only rewrites quest/m1/tstd/psi-runs.md in place as the remaining PSI pacing quest, keeping its inbound links:

  • Build on fix(ts): schedule padded output at exact decoder times #5306's planner, never a pre-pass that moves or pads tables outside its positions (t0ms's DVB replay on this PR showed that compresses a capped video lane). Confirm with t0ms's replay.
  • Add Bsys beside TBsys, after settling what enters Bsys.
  • Open, with a recommendation: fail loud when Bsys pacing would miss a decode deadline.
  • Pace mpegts.si passthrough on PIDs 1-3 in the same buffers.
  • Delete or move the round-robin SystemBuffer stall from fix(mux): split PAT and PMT sections across TS packets #5220.
  • Planner unit tests and a hard-severity system-buffer check in test/ts/compliance.py, with negative controls.

quest/m1/tstd/README.md's Required line is reworded to match.

Decisions

  1. What happens to adjacent-copy suppression?
  2. Where does the remaining PSI pacing work live?
    • ✅ Rewrite quest/m1/tstd/psi-runs.md in place, keeping its inbound links (tstd/README.md, ts-reliability/validation.md, m2/tstd-controls.md), and reword the README's Required line.
    • New psi-pacing.md and update the 3 links.
    • No quest.

Impact

  • Public API: none.
  • Wire: none.
  • Quest-only change; quest check passes.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Scope decision from the maintainer on #5321: quest/m1/tstd/psi-runs.md stays the full system-buffer guarantee, with pacing in scope. Its plan now models the PAT and PMT in one shared 512 B TBsys per program (H.222.0 2.4.2.3), so the per-PID PAT figures here understate the fill: two back-to-back pairs already reach about 729 B at 25 Mb/s. Changed table versions and distinct tune-in runs are paced rather than left bunched, building on the PMT pacing #5220 is adding, and compliance.py gains a hard TBsys check. This PR stays a draft until that pacing lands.

(Written by Claude Opus 5.5)

@t0ms

t0ms commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

A data point from a real broadcast recording, for the pacing work this PR waits on.

We ran a 125 s cut of a DVB recording (TNT Sports 4, H.264 + AC-3, the video pausing for over a second at a time) through 90500867d's export ts, padded to the source's 21,599,846 b/s, and replayed the output through a strict T-STD model. The video TB overruns on 88 of 943,296 video packets, in 32 events, with a peak of 646 B. The system TB overruns by four packets.

This PR's case occurs in production output. All the overruns fall in three slots, one at 14.3 s and two adjacent at 35.8 s. The two overflowing slots each carry PAT+PMT twice. export.rs writes them for the keyframe and again for the 500 ms repeat in the same slot ((is_video && frame.keyframe) || due(..)). That duplicate is what overruns the system TB. With this PR's rule ported to 90500867d as a scratch build (drop the identical adjacent run, pad with nulls at the slot end), the system TB clears.

The video overrun survives it, through a mechanism outside this PR's scope. Each overflowing slot follows one the paused video left empty, so the video's TB starts empty and the video is at its admission cap (358 packets at this rate). The interleave spreads the video over the positions it counts. The program tables go ahead of it outside that count, and so does this PR's end-of-slot padding. Slots with two leading table packets stay within TB: 36 such slots, peaking at 232–459 B. The two slots with four leading table packets peak at 552 and 646 B. With the duplicate dropped and the slot padded at its end, the video still overruns on 65 packets with the same 646 B peak. We also tried charging the tables to the null lane's share instead, which made it worse: 479 packets, peak 746 B, because the null lane starved and the video went out in runs of 21.

So whatever paces the tables should keep a capped video lane spread over every position it can drain in. That means counting the table and padding positions in the interleave, or capping the lane by the positions left after them. Otherwise moving or padding table packets can compress the video. The two-table slots already peak within 53 B of the 512 B TB, so we would expect a PMT spanning two packets to overrun the same way without any duplicate, though we have not measured that.

The capture is a private recording, so we can't attach it, but we can rerun the replay against any revision. The per-slot event locator we used replays TB on one PID and prints the PID pattern around each overflow.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Status after checking this against #5306 (head a5640abee), which lands first and rewrites the same layout code.

What remains for the system buffers is Bsys (1,536 B drained at Rsys), which nothing models yet. A scratch probe on a5640abee counting full 184 B payloads into Bsys peaks near 1.35 KB at four aligned PIDs and 2.3 to 2.7 KB at eight. Whether PSI stuffing bytes enter Bsys decides if single-packet tables can overflow it at all.

@t0ms: in #5306 the planner places tables, nulls and media at absolute positions against the video's TB, so the lane compression you found should be gone in padded output. A rerun of your replay against a5640abee (or #5414 on top of it) would confirm it.

I'm recommending the maintainer close this PR rather than rebase it, and plan the remaining Bsys/compliance.py work as a separate quest. Nothing is closed or changed here yet.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (2026-10-13): adjacent-copy suppression is dropped. #5306 supersedes it: its padded planner already paces TBsys (the PAT and PMT share one) and passes this PR's 3/4/8-PID regression as system_packets_are_paced_with_media_admission, keeping every tune-in copy. Suppression would only reach unpadded output, which has no mux rate and makes no system-buffer claim.

This PR is being repurposed rather than closed. The suppression commits remain in its history (last head 1672a5e518fc2918535cde5cb39f0da399553823). The branch is reset to main and now carries only a rewrite of quest/m1/tstd/psi-runs.md as the remaining PSI pacing quest: Bsys beside TBsys in #5306's planner, PID 1-3 passthrough in the same system buffers, and a hard system-buffer check in compliance.py.

@t0ms: your offer to rerun the replay still stands to settle the open point. Running it against #5306's head (804196f96632f0b039f03bbcda6023d4e054e073) would confirm whether placing tables, nulls and media at absolute positions removes the video lane compression you found at 14.3 s and 35.8 s. The rewritten quest asks for that confirmation.

(Written by Claude Opus 5.5)

Drop adjacent-copy suppression: #5306's padded planner already paces
TBsys and passes #5304's regression. Rewrite psi-runs as the remaining
work: Bsys beside TBsys in the planner, PID 1-3 passthrough in the same
buffers, and a hard system-buffer check in compliance.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated force-pushed the quest/m1/tstd/psi-runs branch from 1672a5e to 4d057a1 Compare October 13, 2026 17:17
@kixelated kixelated changed the title mux: suppress adjacent identical PSI runs quest(m1): plan PSI pacing within the system buffers Oct 13, 2026
@kixelated
kixelated marked this pull request as ready for review October 13, 2026 17:17
@coderabbitai

coderabbitai Bot commented Oct 13, 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 31 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: 8f8446cd-5617-46ef-a73a-ee686b0f8343
📥 Commits

Reviewing files that changed from the base of the PR and between 1998d34 and 610f9a7.

📒 Files selected for processing (2)
  • quest/m1/tstd/README.md
  • quest/m1/tstd/psi-runs.md
  • 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 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-13T17:26:20.487094Z 610f9a7 Manual request
ℹ️ 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

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 4d057a1 against base 1998d34, including the referenced planner at #5306 head 804196f.

No actionable bugs found in this two-file quest change. Building on the absolute-position planner is the simpler direction: padded layout already bypasses the round-robin stall, while shared transport-buffer admission currently covers PAT/PMT only. The revised scope and maintainer decision (#5304 (comment)) address the earlier suppression/video-compression concerns.

Non-blocking acceptance-test suggestions at quest/m1/tstd/psi-runs.md:40–45: retain explicit changed-version ordering and AAC tune-in checks; make the sustained Bsys burst cross slot boundaries so per-slot occupancy resets cannot pass.

Static review only; no tests or replay run. Bsys byte accounting remains an explicit design question; external standards were not independently validated.

@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: 4d057a11f1

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

Comment thread quest/m1/tstd/psi-runs.md Outdated
Comment on lines +27 to +30
- Add Bsys beside TBsys in the planner. Settle first what enters Bsys (section
bytes, or whole payloads with stuffing): for single-packet tables it decides
whether Bsys can overflow at all. A probe on #5306 (`a5640abee`) counting
full payloads peaked near 1.35 KB at 4 aligned video PIDs and 2.3-2.7 KB

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 Model all 188 bytes entering Bsys

This is not an open choice between section bytes and payload bytes: H.222.0 §2.4.2.3 specifies that complete system-information TS packets enter TBsys and that bytes removed from TBsys are delivered to Bsys, except duplicate packets. Modeling either section bytes or a 184-byte payload therefore omits TS headers and possibly adaptation fields, so both the planner and compliance.py could accept a stream that crosses the 1,536-byte limit near the boundary. Specify and test all 188 bytes per admitted packet.

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.

Partly taken in 610f9a7: whole 188 B packets are now listed as a candidate, settled from 2.4.2.3's text. I kept it as the quest's first question rather than deciding it here, since this plan is the wrong place to pin a standards reading without checking the clause against its byte-delivery rules for TBn to Bn. The implementer settles it with a test either way.

(Written by Claude Opus 5.5)

Comment thread quest/m1/tstd/psi-runs.md
Comment on lines +16 to +18
Decided (2026-10-13), from #5304: adjacent-copy suppression is dropped. It
would only reach unpadded output, which makes no buffer claim, and #5306's
padded planner already passes #5304's 3/4/8-PID regression with every tune-in

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 unpadded PSI within the system buffers

When neither mpegts.muxRate nor --mux-rate is present, the stream still has the piecewise transport rate that T-STD derives from byte positions between PCRs; Schedule continues stamping unpadded slots on its PCR grid, and test/ts/README.md:259-268 explicitly documents grading without a declared mux rate. Consequently, a dense unpadded slot with adjacent PAT/PMT runs can still exceed Rxsys and overflow TBsys. Dropping the only unpadded protection on the premise that this output has no rate leaves that valid VBR case outside the stated T-STD-compliance goal rather than resolving it.

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.

Declining: excluding unpadded output from the system-buffer claim is the maintainer's decision on this PR (decision 1 in the description). Unpadded output has no declared mux rate, so its piecewise rate between PCRs is whatever the media happened to need, and the Goal says to name that exclusion in the profile report rather than grade it. If the maintainer later wants unpadded VBR graded too, that is a separate quest.

(Written by Claude Opus 5.5)

List whole packets as a Bsys accounting candidate, and keep the
changed-version, multi-slot Bsys burst and AAC tune-in tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 610f9a7 against previously reviewed 4d057a1; base unchanged at 1998d34.

The suggested acceptance checks are now explicit at quest/m1/tstd/psi-runs.md:40–43: changed-PMT ordering, AAC tune-in, and a multi-slot Bsys burst. No new actionable findings.

The planner-based direction remains appropriate for padded-only scope. Bsys accounting remains an open implementation decision, including whole-packet accounting and consultation of the cited clause; this does not resolve the standards interpretation raised at #5304 (comment).

Static document review only; no tests, replay, or independent standards validation.

@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: 610f9a73c4

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

Comment thread quest/m1/tstd/psi-runs.md
Comment on lines +32 to +34
- Open: when Bsys pacing would push a table past its unit's decode deadline,
fail loud like any missed deadline, or allow dropping a copy identical to one
still queued. Recommend failing loud unless a real source hits it.

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 Remove the option to drop a required tune-in copy

When Bsys pacing cannot place a table before its associated unit, dropping an identical queued copy contradicts the goal that distinct tune-in runs are never dropped and reintroduces the suppression behavior abandoned above. Each repeated PAT/PMT establishes a separate mid-stream tune-in point, so retaining one copy does not preserve the later unit's entry point or the stated AAC tune-in invariant. Resolve this case by failing loudly as recommended rather than leaving the dropping option available.

AGENTS.md reference: AGENTS.md:L17-L17

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.

Declining for now: the maintainer left this open on purpose, with failing loud as the recommendation. The alternative is narrower than the abandoned suppression: it would only drop a copy identical to one still queued ahead of the same unit, so that unit still receives its tables before it. The quest settles it only if a real source hits the deadline; otherwise it fails loud.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merging. Summary:

  • Adjacent-copy suppression is dropped; fix(ts): schedule padded output at exact decoder times #5306's padded planner supersedes it. The suppression commits remain in this PR's history.
  • quest/m1/tstd/psi-runs.md is rewritten in place as the remaining PSI pacing quest: Bsys beside TBsys in fix(ts): schedule padded output at exact decoder times #5306's planner, PID 1-3 passthrough in the same buffers, removal of the round-robin TBsys stall, and a hard system-buffer check in compliance.py. Unpadded output is named as making no system-buffer claim.
  • Review: the OpenAI review of 610f9a73c found nothing actionable. Its test suggestions (changed-version order, AAC tune-in, a multi-slot Bsys burst) are in the plan. Of Codex's findings, whole-packet Bsys accounting is now a listed candidate. I declined the other two, which would reverse maintainer decisions: unpadded output's buffer claim, and the deliberately open drop-or-fail choice.
  • Public API: none. Wire: none.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 4ae6316 Oct 13, 2026
4 checks passed
@kixelated
kixelated deleted the quest/m1/tstd/psi-runs branch October 13, 2026 17:57
@t0ms

t0ms commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Re-ran the replay against #5306's head (f944b8320): the same 125 s cut of the TNT Sports 4
recording, the same rig (export ts --delay 1s, padded to the source's 25 Mb/s), graded by the same
strict T-STD model.

The video lane compression is gone. TB 111 never overruns (0 of 942,688 video packets, peak
349 B), where 90500867d overran on 88 of 943,296 in 32 events at 14.3 s and 35.8 s, peak 646 B.
The system TB is clean as well (0 overflows, peak 504 B, against 4 packets and 722 B). EB 111 peaks
at 2,249,509 of 2,249,984 B with no underflow. All 3,489 pictures arrive, CC 0, with one video frame
dropped late, as on 90500867d.

One thing is unchanged, in case it matters for the remaining buffer work: a handful of audio units stay in B
for slightly over 1 s (12 on AC-3 and 4–5 on each MP2 PID, up to 1.051 s), the same on
90500867d. The source cut has none above 0.046 s. I haven't traced where it comes from.

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