---
title: Least Recently Used Access (LRUA)
url: https://www.emergentmind.com/topics/least-recently-used-access-lrua
type: topic
---

# Least Recently Used Access (LRUA)

Least Recently Used Access (LRUA) refers to cache replacement mechanisms and analysis strategies based on the Least Recently Used (LRU) policy. In LRU replacement, upon a cache miss and when the cache is full, the object that has not been requested for the longest time—the "least recently used"—is evicted. LRU is the canonical stack-based replacement policy, notable for strong recency exploitation and a rich mathematical analysis tradition. LRUA encompasses both analytic modeling of cache hit/miss rates under various demand models and static program analysis for classification of memory accesses.

## 1. Formal Definition and Behavioral Semantics

For a cache of capacity $C$ and a catalog of $N$ distinct objects, the LRU policy is defined as follows:

- On a request for object $o$, if $o$ is present in cache (a hit), $o$ is promoted to the most recently used (MRU) position.
- If $o$ is not present (a miss), and the cache is full, the least recently used object is evicted; $o$ is inserted as MRU.
- The cache can be modeled as an ordered list of up to $C$ items, with the leftmost as MRU and rightmost as LRU.

In static analysis, the set of possible cache states is

$$
S = \{ (s_1, \dots, s_C) \mid s_i \in A \cup \{\bot\}, \ s_i \ne s_j \text{ for } i \ne j \},
$$

where $s_1$ denotes the MRU and $s_C$ the LRU, and $\bot$ marks an empty line. The LRU update for state $s$ upon access to $a$ is defined as:

- If $a = s_i$ for some $i$, move $a$ to $s_1$, shift $s_1$ to $s_{i-1}$ rightward, keep $s_{i+1}$ to $s_C$ unchanged.
- If $a \notin \{s_1, \ldots, s_C\}$, insert $a$ at $s_1$ and shift $s_1$ to $s_{C-1}$ rightward, evict $s_C$.

A hit occurs when $a$ is already in cache; a miss otherwise [1811.01670].

## 2. Analytic Modeling under Stationary and Non-Stationary Demand

### 2.1 Independent Reference Model (IRM) with Power-Law Demand

Under the IRM (i.i.d. requests), object ranks follow a Zipf-like law: $p_i = \Lambda / i^\alpha$, $\Lambda = ( \sum_{j=1}^N j^{-\alpha} )^{-1}$, $i=1,\ldots,N$.

Che et al.'s approximation introduces a mean-field "characteristic time" $r$ such that the steady-state probability object $i$ is in cache is

$$
\pi_i \approx 1 - e^{-p_i r}
$$

with $r$ determined by enforcing the average cache occupancy constraint

$$
\sum_{i=1}^N \pi_i = C \implies \sum_{i=1}^N (1 - e^{-p_i r}) = C \implies \sum_{i=1}^N e^{-p_i r} = N - C.
$$

Traditionally, finding $r$ requires $O(N)$ numerical root finding [0705.1970].

### 2.2 Closed-Form Cubic Approximation

A constant-time closed-form for $r$ is achieved via Taylor expansion and truncation, yielding a cubic equation in $r$:

$$
\alpha_3 r^3 + \alpha_2 r^2 + \alpha_1 r + \alpha_0 = 0
$$

with explicit coefficients in terms of $\Lambda$, $C$, and generalized harmonic numbers $H_N^{(k\alpha)}$. The selected $r$ is the smallest real root $\geq C$, and the per-object hit rate is computed as above.

Aggregate cache hit ratio follows immediately:

$$
H = \sum_{i=1}^N p_i \pi_i
$$

The closed-form is $O(1)$ in $N$ and $C$, as harmonic numbers can be approximated by $H_N^{(s)} \approx (N^{1-s} - 1)/(1-s)$ [0705.1970].

### 2.3 Non-Stationary Traffic Patterns

For non-stationary demand (objects have finite lifetimes and time-varying popularity), a Poisson content arrival process of rate $\gamma$ is assumed. Each object $m$ is published at time $\tau_m$ with total request volume $V_m$, and its request process is $\lambda_m(t) = V_m \lambda(t-\tau_m)$ for shape function $\lambda$ ($\int_0^\infty \lambda(u)\,du = 1$).

Defining $T_C$ as the "eviction time," Che's approximation under non-stationarity yields:

- Probability object $m$ is in cache at $t \gg T_C$:
  $$
  p_{\text{in}} (\tau, V) = 1 - \exp\left( -V \int_{t-T_C}^t \lambda(\theta - \tau) d\theta \right)
  $$
- Marginalizing over $V$ and object arrivals gives integral equations: for expected cache occupancy $C$ and hit probability $p_{\text{hit}}$,

  $$
  C = \gamma \int_0^\infty \left[ 1 - \varphi_V\left(-\int_0^{T_C}\lambda(u - \theta) d\theta \right) \right] du
  $$
  $$
  p_{\text{hit}} = 1 - \int_0^\infty \lambda(u) \frac{\varphi_V' \left( -\int_0^{T_C} \lambda(u-\theta)\, d\theta \right)}{E[V]}\, du
  $$

where $\varphi_V$ is the moment-generating function of $V$. Asymptotic regimes simplify the expressions in the small-cache and large-cache regimes [1301.4909].

## 3. Algorithmic Analysis and Program Classification

### 3.1 Classical Age-Based Abstract Interpretation

For static cache analysis, the age-based abstraction maps each block $b$ to an interval $[\ell_b, h_b] \subseteq \{0,1,\ldots,N-1,\infty\}$. Transfer functions update ages according to LRU rules; at each control-flow join, intervals are merged. Hits and misses are classified as:

- Always-hit: $h_b \le N-1$
- Always-miss: $[\infty, \infty]$
- Unknown: otherwise

This method scales as $O(|V|\cdot|B|\cdot N)$ but may yield 15–40% "unknown" classifications [1811.01670].

### 3.2 Exact Antichain/ZDD-Based Analysis

To attain precision without model checking, the focused antichain/ZDD analysis is introduced:

- For each target block $a$, the concrete cache state w.r.t. $a$ is encoded as either a special "absent" symbol $A$, or the set of all blocks younger than $a$.
- The abstract domain consists of antichains of subsets, representing minimal (for may-hit) or maximal (for may-miss) sets of younger blocks.
- Transfer functions are given by set union and subsumption, and joins are set-wise unions with antichain minimization/maximization.

A worklist-driven fixpoint yields, for each program location, an exact determination: may-hit iff $\emptyset\in\mathcal{A}$, may-miss iff $A\in\mathcal{D}$. Always-hit iff $A\notin\mathcal{D}$, always-miss iff $\emptyset\notin\mathcal{A}$.

On real benchmarks, this method offers 100% classification precision, with runtime and memory usage several orders of magnitude below model checking: average speedup of $249\times$ and maximum $>600,000\times$, using typically $<1$GB memory [1811.01670].

| Method                 | Mean Time      | Peak Memory | Precision |
|------------------------|---------------|-------------|-----------|
| Focused + Model Check  | $\sim 10^3$s  | $\sim 10$GB | exact     |
| ZDD Fixed-Point        | $\sim 10^1$s  | $\sim 1$GB  | exact     |

## 4. Computational Complexity and Practical Considerations

Classical hit/miss decision problems for LRU on acyclic control-flow graphs are NP-complete, both for may-hit and may-miss classification. Membership in NP follows by guessing an execution path and simulating the LRU cache, while NP-hardness is shown via reductions from SAT and Hamiltonian Path, exploiting the combinatorics of inserted and replaced blocks in LRU [1811.01670].

Traditional numeric/simulation-based methods for cache models (e.g., exact Markov chain or iterative Che approximation) typically exhibit $O(N C)$ or higher complexity. The closed-form cubic formulation [0705.1970] and the focused antichain analysis [1811.01670] reduce complexity to $O(1)$ for occupancy/characteristic time and $O(N)$ for per-object statistics.

Accuracy for the closed-form cubic holds rigorously when $C/N \le 10\%$ and Zipf exponent $\alpha \le 0.8$. For larger $\alpha$ or $C/N$, proportional normalization of per-object probabilities restores precision. In non-stationary demand, error relative to simulation is within 2–5% across a broad range of traffic models [0705.1970, 1301.4909].

## 5. Sensitivity to Traffic, Demand, and System Parameters

LRU cache performance is highly sensitive to several parameters:

- **Content lifetime ($L$):** For small caches, hit probability $p_{\text{hit}} \propto 1/L$. Short-lived, bursty objects increase hit rates for fixed $C$.
- **Volume distribution ($E[V]$, $\beta$):** The tail of the request volume distribution ($\beta$ in a Pareto law, i.e., Zipfian exponent) strongly affects hit rates as $C$ scales.
- **Temporal profile ($\lambda$):** Sharply peaked (square) temporal profiles (high $\int \lambda^2$) increase hit probability for small caches.
- **System scale ($C/N$):** Relative cache size modulates approximation accuracy; normalization fixes are effective for $C/N > 10\%$ [1301.4909].

Validation against Monte Carlo simulations demonstrates that these analytic approaches robustly capture cache performance across parameter space, matching simulation results within a few percent for realistic $N$ and widely varying workloads.

## 6. Limitations and Extensions

Che’s approximation and its closed-form descendants assume i.i.d. requests (IRM) or independent Cox processes for generalized traffic. These models neglect higher-order correlations (e.g., user sessions, non-Poisson arrivals, content dependency) and interactions across cache networks or hierarchies. Extensions to multi-class object types are feasible but require a-priori class-mix estimation from data.

For static analysis, all methods assume deterministic LRU behavior, single-level caches, and associative memory; they do not address hardware-specific behavior (e.g., set-associativity conflicts), nor do they handle instruction/data streams jointly.

A plausible implication is that as real-world cache and traffic models become increasingly nonstationary and high-volume, the computational efficiency and accuracy guarantees of closed-form and antichain-based analyses are necessary enablers for multi-cache, multi-object system design, yet must be augmented or hybridized to accommodate full system complexity [0705.1970, 1301.4909, 1811.01670].

Source: https://www.emergentmind.com/topics/least-recently-used-access-lrua