vllm.v1.kv_offload.cpu.policies.arc
¶
Classes:
-
ARCCachePolicy–ARC (Adaptive Replacement Cache) cache policy.
ARCCachePolicy
¶
Bases: CachePolicy
ARC (Adaptive Replacement Cache) cache policy.
Data Structures
T1: Recent cache containing chunks accessed once. T2: Frequent cache containing chunks accessed multiple times. B1/B2: Ghost lists tracking recently evicted chunks from T1/T2. target_t1_size: Adaptive target size for the T1 partition.
Algorithm Flow
-
Cache lookup (lookup): Searches T1 and T2 for chunk hashes and counts consecutive hits until a miss or non-ready chunk is encountered.
-
Request access - Adaptive Learning:
- Ready chunks reused by a request move from T1 to T2 once, or move to the MRU end of T2.
-
B1/B2 misses adjust target_t1_size once per request before insertion removes their ghost entries.
-
Chunk eviction (evict) - Adaptive Replacement: Determines eviction source based on adaptive target:
- If T1 size >= target_t1_size: Evict from T1, add to B1.
-
Otherwise: Evict from T2, add to B2. Finally, bound each ghost list size.
-
Chunk insertion (insert): New chunks are always inserted into T1 and removed from B1/B2 if present. A later request reuse may promote them to T2. While the inserting request runs, eviction takes its chunks tail first, so store batches never leave a resident tail behind an evicted head.
Adaptive Behavior
The algorithm self-tunes the recency vs. frequency trade-off: - B1 hit: Recent access patterns matter more → increase T1. - B2 hit: Frequent access patterns matter more → decrease T1.
_release_running(key)
¶
Forget that a chunk belongs to a running request.
_RunningT1Keys
dataclass
¶
T1 chunks used by a request that has not finished, by position.