Blob Blame History Raw
In versions new enough to have the `-o lru_maintainer` option, a new LRU
mechanic is available.

Previously: Each slab class has an independent doubly-linked list comprising
its LRU. Items are pulled from the bottom and either reclaimed or evicted as
needed.

Now, enabling `-o lru_maintainer` changes all of the behavior below:

 * LRU's are now split between HOT, WARM, and COLD LRU's. New items enter the
   HOT LRU.
 * Items hit at least twice are considered active.
 * LRU updates only happen as items reach the bottom of an LRU. If active in
   HOT, move to WARM, if active in WARM, stay in WARM. If active in COLD, move
   to WARM.
   The exception is that items active in COLD are immediately moved to WARM.
 * HOT/WARM each capped at N% of memory available for that slab class. COLD
   is uncapped (by default, as of this writing).
 * HOT/WARM are also age capped by ratios of COLD's age. IE: HOT is capped at
   N% of memory, or 10% of the age of COLD, whichever comes first.
 * Items flow from HOT/WARM into COLD.
 * A background thread exists which shuffles items between/within the LRU's as
   limits are reached. This includes moves from COLD to WARM.
 * The background thread can also control the lru_crawler, if enabled.

The primary goal is to better protect active items from "scanning". Items
which are never hit again will flow from HOT, through COLD, and out the
bottom. Items occasionally active (reaching COLD, but being hit before
eviction), move to WARM. There they can stay relatively protected.

A secondary goal is to improve latency. The LRU locks are no longer used on
most item reads, largely during sets and from the background thread. Also the
background thread is likely to find expired items and release them back to the
slab class asynchronously, which speeds up new allocations.

It is recommended to use this feature with the lru crawler as well:
`memcached -o lru_maintainer,lru_crawler` - Then it will automatically scan
slab classes for items with expired TTL's. If your items are always set to
never expire, you can omit this option safely.

An extra option: `-o temporary_ttl=N` (when used with lru_maintainer) will make
items with a TTL less than or equal to this value use a fourth TEMP LRU. Items
stored in TEMP are never bumped within its LRU or moved to other LRU's. They
also cannot be evicted. This can help reduce holes and load on the LRU crawler.

Do not set temporary_ttl too high or memory could become exhausted.