How TalonKV Evicts Expired TTL Keys Under a Hard Memory Cap
TalonKV is an embedded key-value storage engine designed for memory-constrained edge workers and sidecar caches. Operators configure a strict hard memory ceiling via max_memory_mb so the host process never triggers an OS out-of-memory kill during traffic spikes.
When resident memory climbs to the default slab eviction threshold of 88% RSS, TalonKV activates its synchronous eviction pass before accepting new writes. Expired TTL keys are reclaimed first; if memory remains above 88% RSS, the allocator runs a 16-key sampled LRU sweep (controlled by evict_batch_size=16) across active slab classes, evicting the oldest idle entries until resident usage drops below the 84% hysteresis watermark.
In steady-state operation, a background sweeper also scans 64 random keys every 250 ms to prune expired TTL entries lazily. However, under sudden write bursts, the synchronous 88% RSS gate and 16-key sampled LRU policy guarantee bounded memory growth without stalling read threads for more than a few microseconds. Administrators can inspect talon_evictions_ttl_total and talon_evictions_lru_total to tune slab sizes and verify whether workloads are hitting the hard cap prematurely.
Pinned keys marked with NO_EVICT are skipped during sampled LRU sweeps, though they still count toward the 88% RSS watermark. If every sampled candidate is pinned, TalonKV returns ERR_MEM_CAP to the writer until space is freed.