High-performance cache policies and supporting data structures.
Feature: policy-two-q
Reduce scan pollution with a simple two-queue design that approximates “access twice before protection”.
Maintain:
A1 (in): FIFO queue for newly admitted items (probation)Am: LRU queue for items that were accessed again (protected/main)Behavior:
A1.A1 is accessed again, it moves to Am.A1 (discard one-hit-wonders) before evicting from Am.Common implementation:
HashMap<K, NodePtr> mapping keys to node pointersA1 (newest at front, oldest at back)Am (MRU at front, LRU at back)Optional (from the original paper):
A1out: “ghost” history of recently evicted A1 items to inform admission/tuning (see TwoQWithGhost)insert: into A1 front (new items enter; oldest at back for eviction)get:
A1: promote to Am front (MRU position)Am: move to Am front (MRU position)evict:
A1 exceeds its target size: evict from A1 back (oldest)Am back (LRU)A1 even if under cap when Am is empty|A1| vs |Am|) via a1_frac parameter