Repository navigation
fix(engine): a running render keeps its cached video frames through other renders' cleanup - #9080
Conversation
…ther renders' cleanup A render now holds each extraction cache entry it reads with a per-process hold file beside the entry. The cache sweep skips an entry while its holder is still running and drops holds left by processes that exited. The render releases its holds when it ends.
The hold scan moves into its own function. The engine size budget rises by the process-liveness check that moved here from producer.
|
Size budget: |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 61c442a. Approving.
Read whole at 9546ed8: extractionCache.ts, processOwner.ts, the changed parts of videoFrameExtractor.ts and renderOrchestrator.ts, and the tests. Since then I read the full diff to this head: only the hold scan moved into liveHolds and the engine size budget rose. Nothing was run.
What I checked:
- A render holds what it reads. The lease is made before extraction and released in the deferred cleanup, and both a cache hit and a miss take the hold in
rehydratePublishedCache, including the two paths where publishing fails. - The sweep skips held entries. It reads each hold file's owner and keeps the entry while that owner is alive; a hold whose owner is gone is removed, so a crashed render does not pin an entry for good.
- The moved liveness check is the same code.
processOwner.tsis byte-equivalent to the file it came from, with the old path re-exporting it. - This head.
liveHolds(rootDir, children, remove)does what the inline loop did, in the same order. The budget rise (packed 522000 to 527892, unpacked 1742862 to 1767535) matches the reason posted on the PR.Fallow auditis green at this head;Buildwas still running when I posted. - Body has the
fails without the fix:line naming a test.
Non-blocking: a hold file that cannot be read, or that some other tool wrote, is never removed, even after its entry is evicted. They are tiny, but they accumulate.
Need: yes, a sweep could remove frames a running render was reading · Size: moderate, most of it the moved file and tests · Reuse: reuses the existing owner-record check instead of a second one · Simpler: no · Structure: fine after the liveHolds split
Risk: medium-low. Worst case of a wrong hold is an entry kept longer than needed, not one removed early.
— Rames
Edit accuracy: accurate 275 (base branch 273), smooth 61 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) Unstable (1)
|
What changes for people
A long render can no longer lose its video frames when another render, or
hyperframes clean, sweeps the shared frame cache. Until now, the only thing keeping a running render's cache entries safe was their age: an entry untouched for an hour could be removed while that render still needed it. The render re-touched its entries only while capturing, so any longer pause left them exposed, for example between extraction and capture.How
<entry>.hold-<pid>, holding the process's owner record. Several renders in one process share the file, and it goes away when the last of them releases.Tests
videoFrameExtractor.vfr.test.ts"another render's sweep leaves the frames a running render found, on a miss and on a hit" (on main the aged entry is swept while both renders still read it).