TinyLFU
TinyLFU is a cache admission policy that admits a new item only if its estimated recent access frequency is higher than that of the eviction victim.
TinyLFU uses reset-based aging, not an exact last-W window. The sample counter and sketch counters are halved at W; for even W, the next reset follows W/2 updates. Scanning counters gives amortized work, not constant worst-case reset latency. Integer halving truncates odd counts. [1]
The doorkeeper tests Bloom membership: a negative lookup inserts only into the filter; a positive lookup updates the sketch and a positive query contributes one. Resets clear the filter. Shared bits and false positives mean not one bit of allocated memory per key. [1] [3]
Window TinyLFU admits items to an LRU window; its victim competes with the main cache's victim. The historical 1% window, 99% segmented-LRU main cache, 10x sample and 8 bytes per entry describe one implementation. A later version adaptively sizes the window and uses 4-bit counters, not a universal property of TinyLFU. [1] [2]
Caffeine v3.2.3 increments its sample counter only if at least one addressed counter increases; saturation can stop this clock. Reset adjusts for odd counters. At capacity 64 and threshold 640, 100,000 direct sketch calls for one key left both estimate and sample counter at 15 without reset; sequential keys reset on call 640. A distinct colliding key inherited estimate 15 before its first access. These are native method-call observations, not a cache benchmark or collision-rate measurement. [4] [5] [6]
A cache hit is not necessarily a sketch update. Caffeine v3.2.3 records enabled hit statistics before offering the read event to a buffer that may reject it. Drained events reach onAccess and the sketch; rejected events are not replayed by that offer. This loses policy observations, not the returned value. [7]
Relations
- related
- Cache admission, Cache pollution, Least recently used replacement, Bloom filter, Request coalescing (cache), Count-Min sketch, BP-Wrapper, Segmented LRU
Advantages
- No ghost entries for evicted keys are kept, whereas ARC tracks keys for about twice the cache size and LIRS needs about three times for its best results. [2]
Limitations
- Plain TinyLFU tends to reject items that arrive in a recency burst before they build up frequency, which is the reason for the windowed variant. [2, 1]
- Clearing the doorkeeper removes the extra one from positive doorkeeper queries; it does not lower every possible key's estimate by one. Counter halving has its own truncation error. [1]
- For variable-size items, Implicit Victims (IV) tests the first victim, Queue of Victims (QV) tests successive victims, and Aggregated Victims (AV) tests their summed estimate; these historical variants differ. [8]
- Early pruning in AV can change promotions and later decisions. In a fixed-estimate LRU example, both variants reject X, but the pruned variant then admits Y while full gathering rejects it. [8, 9]
Citations
- Einziger, Friedman and Manes. TinyLFU: A Highly Efficient Cache Admission Policy. arXiv:1512.00727v2 (2015), sections 3-5.
- Caffeine project. Efficiency: Window TinyLFU and adaptive admission-window sizing.
- Broder and Mitzenmacher. Network Applications of Bloom Filters: A Survey. Author-hosted preliminary version, section 2.1.
- Caffeine v3.2.3, FrequencySketch.java: increment, incrementAt and reset; commit 5227a98b51e02b4d4fbfc2b0e33c362a138f51b1.
- Hesela, isolated native Caffeine FrequencySketch replay: deterministic observations and method, 2026-10-30.
- Hesela, reproducible native FrequencySketch harness with pinned source and integrity verification.
- Caffeine v3.2.3, BoundedLocalCache.java: concurrency contract, afterRead, drainReadBuffer and onAccess. Commit 5227a98b51e02b4d4fbfc2b0e33c362a138f51b1.
- Einziger, Eytan, Friedman and Manes. Lightweight Robust Size Aware Cache Management. arXiv:2105.08770v2 (2021), sections 4.1-4.3.1, Algorithms 2-4.
- Hesela. Cache victim transitions: constructed examples, assumptions and runnable tests.
Sources & caveats
- tinylfu is the 2015 arXiv v2 preprint, read in sections 3 to 5, and not the later journal version.
- caffeine is the efficiency wiki page of an open-source Java caching library maintained by one of the paper's authors, so its comparisons are the proposer's own.
- The 1% window, 10x sample and 8-byte figures describe release 2.0 of that library as reported in the paper.
- Neither source establishes the behaviour of SSD firmware caches.
- The doorkeeper description separates membership-cell width from allocated bits per key. Historical counter-size examples are omitted because width alone does not specify the encoding or inclusive count range.
- The 2026-10-30 native replay compiles the original FrequencySketch source with two explicit capacity-64 helpers and a compile-time annotation. It exercises direct methods, not complete Caffeine request handling or cache performance.