Skip to content

Commit 6a4e196

Browse files
authored
Add tiny lfu to roadmap (#17)
* Update policy documentation to reflect planned and implemented policies - Revised the list of upcoming cache policies in the README to include GDSF and TinyLFU/W-TinyLFU. - Added TinyLFU/W-TinyLFU to the implemented policy summaries in the roadmap documentation, ensuring clarity on current and future features. * Update policy documentation to correct upcoming policies list - Removed outdated references to ARC and CAR from the planned policies section in the README. - Ensured the list accurately reflects the current focus on LIRS, GDSF, and TinyLFU/W-TinyLFU.
1 parent 47c61e7 commit 6a4e196

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

docs/policies/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Enable the corresponding feature flag for each policy. See [Compatibility and Fe
5858

5959
### Roadmap Policies (Planned)
6060

61-
See [Policy roadmap](roadmap/README.md) for upcoming policies (ARC, CAR, LIRS, etc.).
61+
See [Policy roadmap](roadmap/README.md) for upcoming policies (LIRS, GDSF, TinyLFU/W-TinyLFU, etc.).
6262

6363
### Implemented Policy Summaries (Short)
6464

docs/policies/roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ If a policy moves into production code, its document should be moved back to
1414
- [LFU Aging](lfu-aging.md)
1515
- [LIRS](lirs.md)
1616
- [OPT](opt.md)
17+
- [TinyLFU / W-TinyLFU](tinylfu.md)
1718
- [TTL](ttl.md)

docs/policies/roadmap/tinylfu.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# TinyLFU / W-TinyLFU (Admission + Eviction Design)
2+
3+
## Goal
4+
Improve hit rate under skewed and one-hit-wonder workloads by using
5+
frequency-based admission instead of admitting every miss.
6+
7+
## Core Idea
8+
TinyLFU is primarily an **admission policy**:
9+
- Keep an approximate recent frequency sketch (usually Count-Min Sketch).
10+
- On a miss, compare candidate frequency against a sampled victim.
11+
- Admit only if the candidate appears "hotter" than the victim.
12+
13+
W-TinyLFU combines:
14+
- **Window cache** (small recency-focused region, typically LRU)
15+
- **Main cache** (segmented/protected region)
16+
- **TinyLFU admission gate** between window and main
17+
18+
This keeps recent bursts responsive while avoiding long-tail pollution.
19+
20+
## Core Data Structures (Typical)
21+
- Hash index `K -> Entry`
22+
- Window segment (e.g., LRU list or ring)
23+
- Main segment (e.g., SLRU-style probation/protected)
24+
- Frequency sketch (Count-Min Sketch)
25+
- Optional reset/aging counter for sketch decay
26+
27+
## Complexity & Overhead
28+
- Access/update in sketch: O(1) with small constant factors
29+
- Admission decision: O(1)
30+
- Extra memory for sketch and segmented metadata
31+
- Approximate counts can produce false positives, but usually good tradeoff
32+
33+
## Notes For CacheKit
34+
- Fits best as **policy composition**: storage + segmented eviction + admission.
35+
- Keep hot-path updates allocation-free (pre-sized sketch, fixed segments).
36+
- Make admission optional/configurable for apples-to-apples benchmarks.
37+
- Benchmark against `S3-FIFO`, `ARC/CAR`, and `Heap-LFU` on:
38+
- Zipfian
39+
- scan + point lookup mixes
40+
- shifting hotspots
41+
42+
## References
43+
- Einziger et al. (2017): "TinyLFU: A Highly Efficient Cache Admission Policy".
44+
- Caffeine design notes (W-TinyLFU implementation details).
45+
- Wikipedia: https://en.wikipedia.org/wiki/Cache_replacement_policies

0 commit comments

Comments
 (0)