The key pool (slots)

yac.keys_memory_size holds a fixed-size table of slots — the default of 8M gives around 65,536 slots. Each stored key occupies exactly one slot, so this pool caps the number of entries that can exist at once; unlike the value pool, slots are never individually freed. An expired slot — one past its TTL, or the tombstone left by Yac::delete — is recycled for free when a new key needs it. Only when all four candidate slots of a probe path hold live entries is one of them evicted to make room — one kick (the kicks counter of Yac::info).

The eviction picks among the four live candidates of the colliding probe path only:

  • the least recently used one (the oldest atime) is evicted;
  • on a tie the least-hit entry, then the earliest probe position.

A common point of confusion: slots_used reaching slots_size is not an error condition. A cache whose working set of keys is larger than the slot table simply runs at 100% occupancy from then on, evicting and re-inserting as needed. The only thing that says whether the key pool is sized correctly is the hit rate (hits / (hits + miss), computed over the deltas between two Yac::info snapshots rather than the lifetime average). A high kicks count on its own means nothing is wrong — the key distribution is simply not uniform and some probe paths collide more than others. Only when the hit rate and kicks are both bad is the table too small for the key set, and the remedy is a bigger yac.keys_memory_size.

A second consequence of slots never being freed: entries with no TTL (ttl = 0) that are never read again keep occupying a slot until an eviction happens to pick them. If an application stores large amounts of such one-shot data, give those entries a TTL so they expire and can be recycled without displacing live entries, or size the key pool for the full key set.