Skip to content

Prewarm a VOD source before load(): the cache exists, but only after the session that fills it #551

Description

@superuser404notfound

Reported over Discord by the author of Snappier IPTV, who embeds the engine: is there a plan for preloading / caching of VOD content, in the shape KSPlayer offers as an addon?

Half of that already exists, and the half that does not is the half the request is actually about.

What the engine does today

On the VOD paths the engine owns, bytes are already cached on disk for the life of the session:

Two limits follow from where that state lives:

What is missing

There is no way to warm anything before load(). Every session starts cold, and a cold open is not free: measured against a 300 ms origin, a non-fast-start MP4 costs two to three sequential round trips before the first sample read, and on a slow origin the first byte of the data connection is the whole perceived start time (#281 and the layout matrix that came out of it). For a host whose UI knows what is next (the next episode, the item under the cursor), those seconds are spendable in advance and are not being spent.

Shape under consideration

A source-level byte prewarm rather than a segment-level one:

  • A URL-keyed, process-wide store of resident spans, beside SourceContentLengthCache and SuffixRangeSupport, which are already exactly this shape.
  • A public call that fills it for a URL the engine is not playing: the head span, the trailing object where the layout has one, and a bounded run of media bytes.
  • AVIOReader consults it on open, at the same place it consults the retained spans today, so a later load() of that URL adopts the bytes and skips the round trips.

Route-independent across the paths the engine owns (loopback native, software host, side demuxers), and by construction not applicable to nativeRemoteHLS, where the engine issues no requests.

Two things it has to get right:

Explicitly out of scope here: persistence across app launches, and offline download. Those are a different feature with a different lifetime and a different disk contract, and are not needed for the reported case.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions