Repository navigation
Description
What should the engine do?
Summary
AetherEngine.prewarm() currently prefetches the beginning of an HTTP resource into memory, but HTTPDiscIOReader maintains its own independent buffer and does not appear to reuse the prewarmed data.
As a result, when opening a remote ISO/BDMV/DVD image over HTTP, the same beginning bytes may be requested again by HTTPDiscIOReader.
It would be useful if HTTPDiscIOReader could reuse data already fetched by AetherEngine.prewarm().
Current Behavior
The current flow is roughly:
AetherEngine.prewarm(url, byteBudget:)
│
├── fetch opening bytes
└── keep them in the prewarm cache
Later:
HTTPDiscIOReader(url)
│
├── creates its own buffer
└── performs its own HTTP Range requests
The two caches are independent.
For example, if:
await AetherEngine.prewarm(
url: url,
httpHeaders: headers,
byteBudget: 10 * 1024 * 1024
)has already fetched the first 10 MiB, HTTPDiscIOReader may still issue a new Range request for data near byte 0 instead of consuming the already available bytes.
This creates unnecessary network traffic and increases startup latency.
Proposed Behavior
Allow HTTPDiscIOReader to consume the existing AetherEngine.prewarm data when the URL and relevant HTTP request parameters match.
For example:
AetherEngine.prewarm()
│
▼
Opening-byte cache
│
│ shared
▼
HTTPDiscIOReader
│
├── read(0...)
├── seek(...)
└── continue from warm frontier
Ideally, the reader should:
- Check whether prewarmed data exists for the requested URL.
- Reuse the cached opening bytes for reads covered by the prewarm range.
- Avoid issuing duplicate HTTP Range requests for already cached bytes.
- Continue fetching from the end of the prewarmed range when the requested offset exceeds the cached range.
- Preserve the existing adaptive read-ahead behavior of
HTTPDiscIOReader.
Example
With:
await AetherEngine.prewarm(
url: url,
httpHeaders: headers,
byteBudget: 10 * 1024 * 1024
)the following should ideally happen:
HTTP resource
0 ─────────────────────────────── 10 MiB ────────────────>
│ prewarmed data │
│ already in RAM │
└──────────────────────────────────┘
↑
warm frontier
HTTPDiscIOReader:
read(0, ...)
→ serve directly from prewarm cache
read(1 MiB, ...)
→ serve directly from prewarm cache
read(8 MiB, 10MiB)
→ serve directly from prewarm cache
read(10 MiB+, ...)
→ HTTP Range request starting from/around warm frontier
Why This Matters
Remote disc images can require multiple reads during initialization and navigation.
For HTTP ISO/BDMV/DVD playback, avoiding duplicate requests for the opening bytes could reduce:
- startup latency
- redundant network traffic
- HTTP request count
- initial buffering overhead
It would also make AetherEngine.prewarm() useful for both normal HTTP media and HTTPDiscIOReader-based media.
Compatibility
This should be backward compatible.
If no prewarm data is available, HTTPDiscIOReader should continue using its existing buffering and adaptive read-ahead implementation exactly as it does today.
Suggested Acceptance Criteria
HTTPDiscIOReadercan reuse compatibleAetherEngine.prewarm()data.- Reads within the prewarmed range do not trigger duplicate HTTP requests.
- Reads beyond the prewarmed range continue normally.
- Existing adaptive read-ahead behavior remains unchanged.
seek()continues to work correctly.- No significant increase in memory usage beyond the requested
byteBudget.
Environment
- AetherEngine
HTTPDiscIOReader- Remote HTTP(S) ISO/BDMV/DVD playback
AetherEngine.prewarm()
Related Files
Sources/AetherEngine/IO/HTTPDiscIOReader.swiftAetherEngine.prewarm()implementation
I believe sharing the prewarm opening-byte cache with HTTPDiscIOReader would make remote disc-image startup more efficient while preserving the current reader architecture.
Motivating media or use case
none
Area
Codec / container support
Host app / integration context
No response
Would you be willing to open a PR?
No
Activity
superuser404notfound commentedon Sep 26, 2026
Thanks for the detailed report. The diagnosis was right:
HTTPDiscIOReadernever looked at the prewarm store. A warmed.isostill probed its size withbytes=0-0and fetched the head again, and the warm stayed unused in the store.This is fixed on
mainin #648 (merge6bc0d889) and will ship in the next release. What changes:byteBudget. The adopting reader holds the warm, and the store no longer keeps a second copy.Measured with
aetherctl play --prewarmon an authored DVD ISO (49 MB) behind a range origin with 20 Mbit/s and 100 ms per response:One limit: the reader does not pin the warm's redirect target. It follows redirects per request, as it did before.
Most of the remaining startup time is a separate issue. MPEG-PS (DVD VOB) never lets
find_stream_infofinish early, so every DVD open reads the full probe budget. I'm opening a separate issue for it.A retest against your own server would be very welcome once the release is out.
superuser404notfound commentedon Sep 26, 2026
Released in 7.18.0 (
da2b4504).ijuniorfu commentedon Sep 27, 2026
It is simply incredible—the start time of the first frame is more than ten times faster with a prewarm
refactor(prewarm): a warm is the source cache filled ahead of the load