mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 15:37:49 +00:00
With `cache_autotuning` configured, `_expire_old_entries` walks Python's global cache list from the coldest entry and evicts while jemalloc reports too much memory allocated. Rust caches were not on that list, so they were never evicted for memory, which matters once the event cache lives in Rust. Each Rust cache's LRU order is already a sorted run, so the registry merges them without a global list: `CacheRegistry::evict_coldest` keeps evicting from the cache whose coldest entry is coldest, up to a bound and a count. The Python walk calls it before evicting each Python entry, with that entry's last access as the bound, so both sides go coldest first together. It reports the coldest Rust entry left, so Python only calls again once its walk passes that time. Memory is re-read after each batch of 100 Rust evictions, as after 100 Python ones, and `min_cache_ttl` holds for Rust entries too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VpBQxvqZTUvHCMm3u6CR7J