Skip to main content

Module memory_capacity

Module memory_capacity 

Source
Expand description

Single memory capacity manager (#995 Phase 2).

One reclaim formula and one generic, archive-backed, hysteresis reclaim used by every store. Replaces the duplicated reclaim_target_capacity and the per-store hard drops (history drain, procedure/pattern truncate): eviction is now lossless everywhere because the dropped tail is archived (and restorable) before removal.

Functionsยง

reclaim_preview
How many items a reclaim_store would archive for a store at len, without touching the store or the archive. Powers dry-run previews (#995 Phase 6).
reclaim_store
Generic, archive-backed, hysteresis reclaim.
reclaim_target
Live count to settle at after a reclaim: drop ceil(max * headroom_pct) items so a busy store keeps real headroom instead of churning right at its cap. headroom_pct = 0.25 reproduces the prior max - ceil(max/4) target byte-for-byte.
should_reclaim
Whether a store at len should reclaim now. Hysteresis: trigger only at/above the cap rather than continuously keeping N% free, so a store does not reclaim on every write once it nears capacity.