Skip to content

The warm's head is dropped by the cue prewarm and then re-fetched by playback's first read #585

Description

@superuser404notfound

Measured while fixing AE#551 round 2 (PR #584), on a 63 MB MKV served by a Range-logging origin.

A warm adopts an 8 MB head, and AVIOReader keeps that span past the parse on purpose (#281 retest: "the head has now done the job it was kept past the parse for"). The drop rule is the first read that lands outside it:

if !openPhaseActive, !headSpan.isEmpty, spanPos < 0 || spanPos >= Int64(headSpan.count) {
    headSpan = Data()
}

The open phase ends at probeStreams, and the very next thing the native path does is HLSVideoEngine's cue prewarm: a seek to the middle of the title. That read is outside the head, so it drops the span. Playback's first read then goes BACKWARD to the head of the file (the anchored connection sits at the end after a trailing-index parse), and the bytes the warm paid for are fetched again:

3792ms REQ bytes=8388608-41943039      <- pump, starting at the warm frontier
3895ms REQ bytes=0-4194303             <- re-fetching the warm head
4085ms REQ bytes=4194304-8388607       <- and the rest of it

8 MB re-downloaded per session on this path, and the whole warm head is spent on nothing but the parse. The same shape is in the pre-fix log, so this is not from PR #584; the warm just makes it easy to see, and it is the one remaining cost between a warmed session and a cold one.

The rule reads "playback has either moved beyond it or started nowhere near it", and neither is true here: the read that drops it is index work, not playback, and it is followed immediately by a read at offset zero. Worth deciding whether the phase that may drop resident spans should end after the index pass rather than after probeStreams, since the cue prewarm is bounded and known-short.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions