Inferensys

Glossary

Adaptive Replacement Cache (ARC)

Adaptive Replacement Cache (ARC) is a self-tuning cache eviction algorithm that dynamically balances between recency (LRU) and frequency (LFU) to optimize the hit ratio under varying access patterns.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
ALGORITHM

What is Adaptive Replacement Cache (ARC)?

Adaptive Replacement Cache (ARC) is a self-tuning, adaptive cache eviction algorithm that dynamically balances between recency-based (LRU) and frequency-based (LFU) caching strategies to optimize the cache hit ratio under varying and unpredictable access patterns.

Adaptive Replacement Cache (ARC) is a self-tuning cache eviction algorithm that maintains two adaptive lists: one for recently accessed items (T1) and one for frequently accessed items (T2). It dynamically adjusts the size of these lists based on the observed workload, effectively learning whether the access pattern favors recency (LRU) or frequency (LFU). This continuous adaptation allows ARC to outperform static algorithms like pure LRU or LFU, especially under workloads with shifting locality, without requiring manual parameter tuning.

The algorithm's core mechanism involves a ghost list for each main list (B1 for T1, B2 for T2), which tracks recently evicted metadata. When a cache miss occurs for an item in a ghost list, ARC interprets this as evidence to favor that list's policy and grows its corresponding main list. This feedback loop enables online learning of the optimal policy mix. In agent-side caching, ARC is particularly valuable for managing the cache of API responses and computed results, where request patterns from an autonomous agent can be highly dynamic and non-stationary.

ALGORITHM MECHANICS

Key Features of ARC

Adaptive Replacement Cache (ARC) is a self-tuning, adaptive algorithm that dynamically balances between recency-based (LRU) and frequency-based (LFU) caching to optimize hit ratios under varying workloads.

01

Dual Cache Lists (T1 & T2)

ARC maintains two primary LRU lists:

  • T1 (Recency List): Contains items accessed only once recently (new entries).
  • T2 (Frequency List): Contains items accessed at least twice recently, promoting them from T1. A ghost list (B1) tracks recently evicted items from T1, and another (B2) tracks evictions from T2. The sizes of T1 and T2 are dynamically adjusted based on the contents of these ghost lists.
02

Self-Tuning Adaptation

The algorithm's core innovation is its ability to self-tune the balance between recency and frequency without manual parameter tuning. It does this by:

  • Monitoring cache misses to items in the ghost lists (B1, B2).
  • Increasing the target size (p) for the T1 list if a miss occurs for an item in B1 (indicating a need for more recency-focused caching).
  • Decreasing p if a miss occurs for an item in B2 (indicating a need for more frequency-focused caching). This continuous adjustment allows ARC to adapt to changing access patterns in real-time.
03

Ghost (History) Buffers

ARC uses non-resident ghost buffers (B1 and B2) to track metadata about recently evicted items. These buffers store only the keys, not the data values.

  • Purpose: They provide a low-memory-cost history of recent evictions.
  • Mechanism: On a cache miss, ARC checks these buffers. A 'hit' in a ghost buffer signals that the eviction policy may be suboptimal for the current workload, triggering the adaptive resizing of T1 and T2. This history is critical for the algorithm's learning capability.
04

Optimal for Mixed Workloads

ARC is specifically designed to outperform static algorithms like pure LRU or LFU when access patterns are unpredictable or mixed. It excels in scenarios where the workload shifts between:

  • Scanning/Looping: Sequential access patterns where LRU fails.
  • Repeated Access to a Subset: Frequency-biased patterns. By dynamically rebalancing, ARC provides near-optimal performance across these shifts, preventing the drastic performance drops seen in fixed policies.
05

Complexity & Implementation

Despite its adaptive nature, ARC maintains manageable operational complexity:

  • Time Complexity: O(1) for all core operations (lookup, insertion, promotion, eviction).
  • Space Complexity: Requires overhead for the ghost lists (keys only) and metadata for tracking the adaptive parameter p.
  • Implementation Challenge: The logic for managing four interlinked lists (T1, T2, B1, B2) and adapting p is more complex than LRU, but libraries like lru-cache for Node.js offer production-ready implementations.
06

Use Case: Agent-Side Caching

In AI agent systems, ARC is highly effective for semantic or deterministic caches storing LLM responses or API call results. Its benefits include:

  • Adapting to User Session Shifts: As a user's conversation with an agent changes topics, ARC can adapt its caching strategy.
  • Handling Bursty, Non-Stationary Data: Ideal for the unpredictable query patterns typical of interactive agents.
  • Maximizing Utility of Limited Memory: By self-tuning, it ensures the limited cache memory in an agent's runtime is used for the data patterns most likely to recur.
CACHE EVICTION ALGORITHM COMPARISON

ARC vs. LRU vs. LFU

A technical comparison of three fundamental cache eviction policies, highlighting their operational mechanisms, performance characteristics, and suitability for different access patterns.

Feature / MetricAdaptive Replacement Cache (ARC)Least Recently Used (LRU)Least Frequently Used (LFU)

Core Eviction Principle

Dynamically balances between recency (LRU) and frequency (LFU) using two adaptive lists (T1, T2) and two ghost lists (B1, B2).

Evicts the item that has not been accessed for the longest time.

Evicts the item with the lowest historical access count.

Self-Tuning / Adaptivity

Memory Overhead

High (Maintains 4 lists and metadata for adaptation).

Low (Maintains a single recency-ordered list).

Medium to High (Requires maintaining and updating frequency counters for each item).

Resistance to Scan/One-Time Access

High (Ghost lists protect against one-time scans polluting the cache).

Low (A sequential scan flushes the entire cache).

Medium (One-time accesses get low frequency counts but still pollute the cache until evicted).

Handling Shifts in Access Pattern

Excellent (Automatically adjusts the balance between LRU and LFU based on observed misses).

Poor (Requires the entire cache to turn over to adapt to a new pattern).

Poor (Historical frequency counts become stale and slow to adapt to new patterns).

Typical Implementation Complexity

High

Low

Medium

Optimal Use Case

Workloads with mixed or unpredictable access patterns (e.g., databases, file systems, agent-side caching).

Workloads with strong temporal locality where recent items are likely to be re-accessed.

Workloads with stable, long-term popularity trends (e.g., static content with known hot items).

Worst-Case Scenario

Higher memory overhead for small caches.

Thrashing on sequential or looping access patterns larger than the cache.

Cache pollution by old, high-frequency items that are no longer relevant.

ADAPTIVE REPLACEMENT CACHE (ARC)

Frequently Asked Questions

Adaptive Replacement Cache (ARC) is a foundational algorithm for optimizing data retrieval in AI agents and high-performance systems. These questions address its core mechanisms, advantages, and practical applications.

Adaptive Replacement Cache (ARC) is a self-tuning, adaptive cache eviction algorithm that dynamically balances between recency-based (Least Recently Used - LRU) and frequency-based (Least Frequently Used - LFU) caching strategies to optimize the cache hit ratio under varying and unpredictable data access patterns.

Developed by IBM researchers Nimrod Megiddo and Dharmendra S. Modha, ARC maintains two LRU lists: one for recently accessed items (T1) and one for items accessed at least twice (T2), representing frequency. It also tracks two ghost lists (B1, B2) of recently evicted items from T1 and T2. The algorithm's core innovation is its adaptive parameter, p, which it continuously adjusts based on the observed hit rates in the ghost lists. If hits occur in B1 (suggesting recency is more important), p increases, favoring the LRU list (T1). If hits occur in B2 (suggesting frequency is more important), p decreases, favoring the LFU list (T2). This real-time feedback loop allows ARC to outperform static policies like pure LRU or LFU, especially in workloads with shifting access patterns.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.