Repository navigation
fix(playback): cap concurrent subtitle demuxes of source files - #4318
Merged
Merged
Conversation
A whole-track subtitle request for a track the file's index can't read (no Cues, an unsupported container) demuxes the whole source with FFmpeg, and so do window fallbacks and jellycompat's text extracts. Nothing counted these runs, so requests for many distinct tracks started as many full-file reads at once. Requests now share four demux slots per process across the native, jellycompat and transcode-node subtitle caches. A demux past them is refused with ErrSubtitleReadsBusy, which the native, node and download routes already answer 503 with Retry-After; jellycompat now does too instead of a 500. Requests joining a running demux, conversions of kept or index-read packets, warms and AI translation jobs take no slot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 15, 2026
Contributor
Quick104
added a commit
that referenced
this pull request
Nov 19, 2026
Resolve conflicts with main's subtitle demux admission (#4318) and its test pruning (#4465). serveWindowedSUP keeps this branch's rooted Lookup and main's demux admission and slow-read warm. The refused-dir kept-copy check moves to its own test, since main removed the table it was a row of. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: none
Other clients: Apple Silo-Server/silo-apple#1183; Android Silo-Server/silo-android#940; Roku Silo-Server/silo-roku#86. Web N/A (its subtitle window and ASS loaders already retry failed requests)
When the file's index can't read a subtitle track (a Matroska file without Cues, an M2TS or another container the index doesn't read), Silo demuxes the whole source file with FFmpeg to get it. Nothing limited how many of those demuxes ran at once. A signed-in user who requested many uncached tracks or formats started one full-file read per request, and those reads starve the playback streams reading from the same storage. This change caps request-driven subtitle demuxes at four per server process. A request past the cap gets
503withRetry-After: 5.On a dev deployment, a 3 GB Matroska file without Cues sat on simulated slow storage. Eight concurrent whole-track requests for its eight subtitle tracks ran eight FFmpeg demuxes of the file at once for about 70 seconds. keptsub's admission (16 whole-track flights) counts only reads through the index. The demux it falls back to, the window fallbacks and jellycompat's text extracts all ran outside any limit, and
streamFullTrackshares a demux only between requests for the same track and format.Approach
The three subtitle caches in a process (native API, jellycompat, transcode node) share one set of four slots in
internal/playback. A slot is taken just before FFmpeg reads the source, for:These take no slot: requests that join a running demux, conversions of kept or index-read packets, windows read from a cached
.sup, background warms (they keep their two warm slots per cache), and AI translation jobs (bounded by their job slots).Past the cap the request is refused at once with
ErrSubtitleReadsBusy, the error keptsub already returns when its reads are full. The native, transcode-node and download routes already answer it with503andRetry-After: 5; jellycompat now does too, instead of a500. Refusing instead of queueing keeps a burst of requests from holding connections, fill reservations and temp files while they wait. The new bound is documented indocs/architecture/embedded-subtitle-index.mdand the jellycompat answer indocs/jellycompat-subtitles-api.md.Validation
200and four answered503withRetry-After: 5within about a second. Requesting those four again once the first finished served all four, so finished demuxes free their slots.Subtitles/{index}/stream.srtrequest on main started a fifth demux beside them. On this branch it answered503withRetry-Afterand the count stayed at 4.-race.make lint-changed: no issues. The playback, jellycompat, proxy, downloads, api/handlers and keptsub packages pass, exceptTestCopyRemuxSubtitleRenditionRealFFmpeg, which fails on main on the test host's FFmpeg 6.1.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/bound-subtitle-demuxes/
Risks
503. This happens when a WebVTT whole track's index read runs past the 5-second keepalive, which has already sent header bytes, and when a fill's temp file fails and a viewer's own fallback demux is refused.503lose the subtitle under load: Roku sidecars, and Apple and Android offline downloads, which drop the sidecar and don't fetch it again later. The same503already happens today when keptsub's reads are full. The parity issues above cover each one.docs/architecture/embedded-subtitle-index.md; whichever merges second needs a rebase.Checklist
AI Disclosure
503. The second rejected queueing jellycompat and committed WebVTT requests behind the cap, because the waiting requests would pile up without limit and starve native ones, so the change refuses everywhere and the risks above describe the cost. A multi-agent code review at xhigh effort (finders, a verifier, a sweep) led to the second round, a doc correction for AI translation, keeping the index read's failure in the refusal error, and the risks above. A simplify pass ran on the change. A background adversarial review (gpt-6.1-sol, reviewed a52b2c9) found nothing.🤖 Generated with Claude Code
Note
Return 503 with
Retry-Afterwhen subtitle demux limit is hitRetry-Afterinstead of a 500jellycompat.writeSubtitleExtractError, which mapsplayback.ErrSubtitleReadsBusyto a 503 usingplayback.SubtitleReadsRetryAfter; all other extraction errors still return 500 (streams.go)PlaybackHandler.HandleSubtitleStreamcan now return 503 ServiceUnavailable; clients that treated any failure as permanent should retry on 503Macroscope summarized a52b2c9.