What Each Pool Holds

The two pools store different halves of an entry. The key pool holds the keys: one slot per cached key, carrying the key itself (up to 48 bytes) together with its hash, TTL, hit count and last-access time; the value is only referenced through a pointer to the value pool. The value pool holds the values: every stored value occupies one block of serialized bytes — the compressed form when the entry went through yac.compress_threshold.

The one exception is embedded values: tiny scalars — null, true, false, most integers (those that fit in 60 signed bits on 64-bit builds), strings of up to 7 bytes and empty arrays — are stored directly inside the slot, in the pointer that would otherwise reference a block. Such values occupy no space in the value pool at all; only their key does.

As a rough sizing guide:

  • the key pool holds around 8,000 keys per MB, so size yac.keys_memory_size as the number of distinct keys divided by 8,000 per MB, rounded up — the default 8M holds around 64,000 keys;
  • the value pool must hold every value that may still be read, so size yac.values_memory_size as the number of live values times their average serialized size (after compression), and allow roughly twice that: the pool is a ring, and a value only dies once the allocator cursor comes back around to overwrite it.
Embedded values occupy a slot like any other entry, but consume no space in the value pool, so leave them out of the second calculation.