Skip to content

feat(io): a remote disc image adopts a prewarmed source (AE#647) - #648

Merged
superuser404notfound merged 1 commit into
mainfrom
feat/ae647-disc-reader-prewarm
Sep 26, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
feat/ae647-disc-reader-prewarm

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Refs #647.

HTTPDiscIOReader never consulted the prewarm store. On a warmed .iso the disc reader probed the size with bytes=0-0, fetched the head again into its own buffer, and left the warm in the store until something evicted it.

Change

  • HTTPDiscIOReader.takePrewarm(for:extraHeaders:) takes the warm under the same rule AVIOReader uses (head at zero, size stated, headers equal).
  • A reader built with prewarmed: uses the warm's size instead of the range probe. Reads inside the warmed spans come from RAM, a refill stops at the next span, and the first request starts at the warm frontier. The adaptive window treats that frontier as a sequential continuation.
  • makeIndependentReader() passes the spans (immutable Data, no copy) and the known size, so forks (subtitle side reader, forward prefetcher) skip the probe and the head.
  • Demuxer.openHTTP: when a disc-image URL turns out not to be a disc, the warm goes back into the store, and the streaming AVIOReader it falls back to adopts it.
  • Not included: pinning the warm's redirect target. This reader follows redirects per request, as it did before.

Measured

aetherctl play on a dvdauthor-built DVD ISO (49 MB) served by a logging range origin at 20 Mbit/s with 100 ms per response:

requests after the warm first frame
main, cold 19 (incl. bytes=0-0) 29.6 s
main, --prewarm 19, same as cold, warm unused ~29 s
this branch, --prewarm 10, first at 8388608 23.9 s

Most of the remaining time is find_stream_info. MPEG-PS sets AVFMTCTX_NOHEADER and never clears it, so every DVD open reads the full playback probe budget (50 MB / 60 s). That is a separate issue.

Tests

Issue647DiscReaderPrewarmTests runs against ThrottledOriginServer with a patterned body:

  • reads inside the warm issue no request and the size is not probed
  • a read across the frontier returns the exact bytes and starts fetching at the frontier
  • a fork shares the warm and makes no request
  • a warm fetched with different headers is not adopted
  • a disc-image URL that is not a disc hands the warm to the streaming reader. This test fails when the hand-back line is removed.

Full suite green locally: 3522 swift-testing tests + 17 XCTest.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mf4MXgM9bqugHoe5TW4BYf

HTTPDiscIOReader never looked at the prewarm store: a warmed .iso was
fetched, then the disc reader probed its size with bytes=0-0 and pulled
the head again while the warm sat unused until eviction.

The reader now takes the warm under the same rule AVIOReader adopts by
(head at zero, size stated, headers equal), uses its size instead of the
probe, serves reads inside the warmed spans from RAM and starts its first
request at the frontier. Forks share the spans and the size, so a
subtitle side reader or forward prefetcher no longer re-probes either. A
disc-image URL that is no disc hands the warm back to the store for the
streaming reader it falls back to.

Measured with aetherctl on an authored DVD over a 20 Mbit/s, 100 ms
origin: 10 requests after the warm instead of 19, first frame at 23.9 s
instead of 29.6 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mf4MXgM9bqugHoe5TW4BYf
@superuser404notfound
superuser404notfound merged commit 6bc0d88 into main Sep 26, 2026
7 checks passed
@superuser404notfound
superuser404notfound deleted the feat/ae647-disc-reader-prewarm branch September 26, 2026 13:50
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