Repository navigation
Conversation
There was a problem hiding this comment.
Automated review
The PR lets DetourBlockCache raise its ceiling by one each time a block the ceiling evicted is inserted again, up to 16 blocks (~64 MB). Idle release brings the ceiling back down, never below 8. The fix sits in the engine at the cause: a working set one larger than the LRU evicts every block just before its next read. The direction is right.
Findings
- No blocking or should-fix findings. I traced
insert,evictIdleandclearat the head against each new test, and they behave as the tests claim:- 5 regions over a ceiling of 3 grows to 5 and stops fetching.
- 9 regions with a cap of 5 never grows, because
evictedByCeilingis capped atgrownMaxBlocks, so a block that returns too late no longer counts. - 12 regions over 8 grows to 12 in the second pass and fetches nothing in the third.
evictIdlereturns early when nothing is idle, so the once-a-second sweep does not wipe the eviction history between passes. When blocks are released, the shrink goes down tolru.count, so it never causes an eviction cascade.- For the maintainer: the PR body offers a fixed ceiling of 12 as a one-line alternative, and
DetourCacheWorkingSetReaderTestspasses with either version. Adaptive or fixed is a judgment call, not a defect.
Checklist: CHANGELOG yes, docs n.a. (no doc quotes the detour cache size), tests yes, traits both ways n.a.
Needs a device run: the per-reader memory peak on Apple TV with a grown ceiling (up to 64 MB of detour blocks, until idle release). Also whether the #909 file plays without rebuffering on tvOS against a slow origin. The author ran this only on macOS.
Thanks for the careful measurements and for offering the fixed-ceiling alternative alongside the adaptive one.
Automated review by Quint (Claude) of 72776f6. It reads the code, it does not build or run it; a maintainer reviews and merges.
… blocks (AE#909) An MP4 that stores each subtitle track in its own region keeps about one detour block per track live during playback. With more such regions than the 8-block ceiling, LRU evicted every block just before its next read and each read fetched it again. A block the ceiling evicted being inserted again now raises the ceiling by one, up to 16 blocks; idle release brings it back down, never below 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72776f6 to
1af29e2
Compare
There was a problem hiding this comment.
Automated review
I checked the new head 1af29e2 and found nothing new since the last review of 72776f6. The cache logic in DetourBlockCache (insert, evictIdle, clear) is the same as before, and the earlier summary still applies.
Automated review by Quint (Claude) of 1af29e2. It reads the code, it does not build or run it; a maintainer reviews and merges.
…old (#909) The growth from 6a337ad counted any return of an evicted block, so a cycle longer than the ceiling still grew the cache to 24 blocks (~96 MB) and kept missing on every lookup at that size. The evictions since the returning block measure how far the cycle outruns the cache; growth now needs that to fit under the ceiling. Takes the reach rule and the reader-level working-set test from #911, which arrived at the same design independently and first. Re #909, supersedes #911 Co-Authored-By: oxyc <m@oxy.fi> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeT6NfHusKtayhPhQfndbo
|
Thank you for this, and sorry for the overlap. #909 got a fix on main in 6a337ad (merged in 2ef4c42) that landed the day after this PR was opened, and it turned out to be the same design almost line for line: a list of blocks evicted for capacity, +1 on a re-fetch, the idle sweep shrinking back, Two things here were better than what landed, so I took them over in 1e42237 (merged in ffbbc3b), with you as co-author:
The ceiling stays at 24 rather than 16: with the reach rule the cache only grows when the larger size actually turns misses into hits, and #104 had 16 subtitle tracks plus blocks straddling a boundary. Closing this as superseded. Both pieces will ship in the next release, and a retest of the #909 file on top of main would still be very welcome. |
Problem
#909: an MP4 that stores each subtitle track in its own region keeps about one detour block per track live during playback, because every embedded subtitle track is harvested (#112). With 14 such tracks the 8-block LRU evicts each block just before its next read, so the same blocks are fetched over and over. Against an origin that takes a few hundred milliseconds per request, playback rebuffers every 10–30 s.
Change
DetourBlockCacheraises its ceiling by one when a block the ceiling evicted is inserted again, up to 16 blocks (~64 MB). The existing idle release (PERF-108) brings it back to what is still resident, never below 8. These never grow it:On the reader, the change is the extra argument the cache is constructed with.
The one-line alternative
For this file, a fixed ceiling of 12 is enough on its own. It was the smallest that held: 0 rebuffers in two runs, against 3 rebuffers at 10.
This PR offers the adaptive version because the size needed depends on how many regions a file keeps live, so any fixed number fits one file's layout. Its cost is about 40 lines in one class, against one line for a fixed ceiling. A fixed 16, for example, can hold up to 32 MB more of a scrub's blocks until idle release; the adaptive ceiling grows only when blocks come back.
DetourCacheWorkingSetReaderTestspasses with either version, so switching to a constant is just that line.Test plan
Media: the #909 file. MP4, HEVC 2160p Dolby Vision, E-AC-3, 14
mov_texttracks stored at 0.76–1.04 GB while video and audio sit at about 4.8 GB.Harness:
aetherctl play --seconds 90 --subs eng --start-position 1500against a local range server adding 400 ms per response; macOS 27.0, Apple silicon.Tests:
DetourBlockCacheTests: seven new cache-level tests covering growth, the bound, the three cases that must not grow, idle shrink andclear.DetourCacheWorkingSetReaderTests: three passes over twelve regions behind the streaming window. The third pass fetches nothing. With growth disabled every pass fetches all twelve ([12, 12, 12]).Run locally on Xcode 27:
swift test;xcodebuild build-for-testingfor tvOS Simulator;swift build -c release --product aetherctl.Not covered:
HLSLocalServerSlowPeerTests"LAN peers cannot take the slots kept for loopback" times out on this machine with and without this change. It looks environmental.sending 'codecpar' risks causing data racesin the undecodable-format gate #883): this machine cannot run Xcode 26. The change adds no closures, literals or long expressions of the kinds Package no longer builds on Xcode 26.3 (Swift 6.2.4) from 7.43.0:sending 'codecpar' risks causing data racesin the undecodable-format gate #883 fixed.🤖 Generated with Claude Code