Skip to content

fix(demux): the index pass is not playback, so it keeps the head (AE#585) - #596

Merged
superuser404notfound merged 2 commits into
mainfrom
fix/585-index-pass-keeps-the-head
Sep 22, 2026
Merged

superuser404notfound merged 2 commits into
mainfrom
fix/585-index-pass-keeps-the-head

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

A warmed session re-downloaded its whole warm head, which was the one remaining cost between a warmed session and a cold one.

The shape

The reader's open phase ends at probeStreams, and the very next thing the native path does is the cue prewarm: a bounded seek to the middle of the title so libavformat loads the container index. That read lands outside the retained head, so #281's drop rule fired on it, on the premise that playback had either moved beyond the head or started nowhere near it. Neither was true. Step 6 resets the cursor to zero immediately afterwards, and playback's first read then paid a fresh connection for bytes the warm already held.

The change

The premise is the read being playback's, so the index pass says it is not, and the rule stands unchanged around it.

  • AVIOReader holds resident spans while indexPassActive, and releases them exactly as before outside it.
  • HLSVideoEngine brackets from decideCompositionOffsetRepair to the step 6 cursor reset, both of which already run only for a non-live session.
  • AVIOProvider's beginIndexPass / endIndexPass default to no-ops, so the custom-reader bridge and every other provider are untouched.

Measurement

46,738,174 B MKV with Cues at the end, served by a Range-logging origin with 50 ms before every response header, aetherctl play --prewarm --seconds 12:

arm requests bytes fetched
before 5 50,334,221
after 3 41,945,613

The two that disappear are bytes=0-4194303 and bytes=4194304-8388607, the warm head a second time. The line that could not appear before now does:

[AVIOReader] pump retained file head served playback's first read at 752; no reconnect for it

Cold control, same fixture without --prewarm: 3 requests on both arms, same shape, so nothing changes where there is no warm to keep.

Tests

Issue585IndexPassKeepsTheHeadTests pins both halves: the prewarm's seek does not release the head, and the release works again once the pass has ended. The second one fails if the bracket is left open, which is the way this change could quietly cost footprint instead of saving round trips. 3325 tests green on both runners, iOS-Sim and tvOS-Sim BUILD SUCCEEDED.

Reported in #585.

🤖 Generated with Claude Code

https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f

Vincent Herbst and others added 2 commits September 22, 2026 11:18
…585)

A warmed session re-downloaded its whole warm head. The open phase ends at
probeStreams, the next thing the native path does is the cue prewarm (a bounded
seek to the middle of the title for the container's index), and #281's drop rule
fired on that read: not at the head, so playback must have moved away. It had
not. Step 6 resets the cursor to zero immediately afterwards, and playback's
first read then paid for bytes the warm already held.

The rule's premise is the read being playback's. The index pass says it is not,
and the rule stands unchanged around it: AVIOReader holds resident spans while
indexPassActive, HLSVideoEngine brackets from decideCompositionOffsetRepair to
the cursor reset, and AVIOProvider's default is a no-op so no other provider
changes behaviour.

Measured on a 46,738,174 B MKV (Cues at the end) over a Range-logging origin at
50 ms per response header, aetherctl play --prewarm:

  before  5 requests, 50,334,221 B fetched
          bytes=8388608-41943039, then bytes=0-4194303 and bytes=4194304-8388607
  after   3 requests, 41,945,613 B fetched, the two re-fetches gone

The line that could not appear before now does: "retained file head served
playback's first read at 752; no reconnect for it". Cold control without a warm
is unchanged, 3 requests on both arms, same shape.

Pinned in Issue585IndexPassKeepsTheHeadTests: the prewarm's seek does not release
the head, and the release works again once the pass has ended. 3325 tests green
on both runners, iOS-Sim and tvOS-Sim BUILD SUCCEEDED.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f
@superuser404notfound
superuser404notfound merged commit a5feb45 into main Sep 22, 2026
7 checks passed
@superuser404notfound
superuser404notfound deleted the fix/585-index-pass-keeps-the-head branch September 22, 2026 09:38
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