Commit Graph
8 Commits
Author SHA1 Message Date
vangel76 6138211804 #3298: cache policy: slow value decay, the process's measured memory, a bounded preview overage, disk writes that pay off, capped open files
- Value decays by ln(seconds unused + 1) + 1 instead of halving every 30 s.
- Each balance reads the process's resident memory (memory-stats, at most every 250 ms): over
  95 % of the RAM left after the reserve the caches give way by what it is over; what they
  freed for it counts as freed; over all of it also protected preview frames go.
- Frames a playing preview shows next go last and may keep the caches over the budget by a
  tenth of it (at most 1 GB).
- Frames and plane sets go to the disk cache only when making them again costs more than
  reading them back (measured read rate, 10 ms per MB until measured).
- At most 256 movie/audio files stay open (least recently used idle one closed).
2026-11-09 01:16:30 +01:00
vangel76 a6ed380638 #3298: the localizer deletes copies without a record and never leaves old bytes beside a new record; set_budget doc says when it frees 2026-11-09 00:39:24 +01:00
vangel76 d0aba3d96e #3298: a balance asked for while another runs is not lost, and a poisoned lock doesn't stop balancing
set_budget during a running balance was skipped (the running pass kept the old budget);
balance() now marks a request the lock holder runs again, also when note_growth held the lock.
A poisoned balancing lock is taken over instead of counting as busy forever.
2026-11-08 18:26:03 +01:00
vangel76 1d6f870e55 Merge remote-tracking branch 'origin/footage-cache-3271' into cache-defaults-3298
# Conflicts:
#	crates/engine/src/settings/session_settings.rs
#	crates/media/src/exr_channels.rs
#	crates/media/src/exr_planes.rs
#	crates/media/src/pool.rs
#	crates/render/src/memory.rs
#	docs/preferences.md
2026-11-08 16:42:46 +01:00
vangel76 607d29050d #3298: the caches share one memory budget from RAM Reserved for Other Applications
The Layer Cache, Footage Frame Cache and Preview (RAM) Cache settings are gone. The big caches
(layers, footage frames, OpenEXR planes, preview frames, the disk write queue) share one budget:
80 % of the installed RAM left after the reserve (5 GB while RAM is unknown, 3.5 GB in the
browser, at least 192 MB). No cache has a share of its own; the memory accountant frees the
least valuable item first across all of them: cost to make again per byte, decayed by time
unused, a copy worth nothing, a thrashing cache protected. Host sessions (CLI, MCP) apply the
budget from the start. Low-memory halving holds until twice the threshold is available again,
with one toast per episode. Saved settings lose the three old keys and keep the reserve.
2026-11-08 14:24:56 +01:00
vangel76 d4cb440527 Footage cache (#3271): decoded OpenEXR channels share the Footage Frame Cache with the frames
The plane store had a fixed 1 GB budget of its own, outside the preferences: with a Footage Frame Cache of 10000 MB it still held about 2.5 frames of a 69-channel 1080p file. The plane store and the media pool's frame cache now share the Footage Frame Cache (set_cache_budget sizes both and the memory accountant's footage group), with one least-recently-used order: each use takes a stamp from one shared counter, and over the footage budget the accountant drops the least recently used item, frame or plane set, whichever holder keeps it. Neither side has a share of its own. The common budget no longer adds a separate plane budget; the browser keeps its 512 MB cap on the planes. Tests: a footage budget of 10000 MB sizes the plane store (and resizes it at run time); filling the frame cache drops the oldest plane sets and filling the plane store drops the oldest frames (fails without the shared order: the frames went first); an accountant group shares its budget.
2026-11-08 13:07:30 +01:00
vangel76 d91f5d28fd Footage cache (#3271): stage B review fixes
- A region of interest reads rows only at the top level (no collapsed precomps, no nested
  comps, no adjustment layers); input and footprint keys never keep a rows-only buffer; a rows
  request takes the whole frame from the frame cache when it is there and keeps nothing itself.
- Sequence layers are keyed by their frame (without frame blending or fields), so times within
  a frame share the entry.
- A decode taken over by a decode thread runs under the asker's cancel flag and hints.
- Disk planes: one entry per channel, read back whatever was asked for before; queued planes
  are moved in (counted exactly), written by channel with checked math; the write refused when
  a plane is of another size. Segmentations are compressed on the writer thread.
- Memory accountant: the plane budget is in the sum; the disk queue counts only bytes it alone
  holds and never drops frame writes; one balance at a time, inserts balance at most every
  100 ms, a refilling holder stays protected for 10 s.
- Reload Footage gives thumbnails new keys; thumbnail keys are worked out at most every 0.25 s.
- Localizer: network footage locations (Settings > Disk, e.g. P:\) besides UNC paths; copies
  recorded beside them and adopted after a restart, stale temporaries deleted; the disk cache's
  reserve kept free; by default beside the disk cache's folder, 20 GB; a copy gone meanwhile
  reads the share; status shown translated, with the network locations.
- Tests: hooks hold the queued decode for the claim test; the disk test uses its own paths.
2026-11-08 03:59:09 +01:00
vangel76 d4a86e037e Footage cache (#3271): one memory accountant over the big caches
render::memory::Accountant: one budget (the sum of the Memory & CPU budgets) over the holders
that register with it: the footage frames (priority 0), the disk write queue (0), the decoded
footage planes (1) and the layer cache (2). Over the budget it frees lowest priority first,
down to 90% of it; a holder that makes again what it just let go of (the layer cache tells its
refills) is protected while it thrashes. Holders are held weakly and balanced after their own
inserts, with their locks released.
2026-11-08 03:05:18 +01:00