CLOCK cache replacement
CLOCK is a cache replacement policy that gives referenced entries another chance by clearing their reference state during an eviction scan.
CLOCK keeps cached pages in a circular buffer with one reference bit each. A hit sets the bit, and on a miss the hand clears set bits as it passes and evicts the first page whose bit is already clear. Setting a reference bit avoids the shared recency-list movement of conventional LRU. This removes that source of hit-path contention, not every synchronization requirement of a complete concurrent cache. [3] Dating from 1968, it approximates LRU but remains scan-vulnerable. [3] [4]
Second Chance, CLOCK and FIFO-Reinsertion are implementations of the same eviction algorithm. SIEVE also keeps one visited bit per object but leaves a retained object in its old position instead of reinserting it among new objects. On 1559 traces from 7 sources it had a lower miss ratio than the best of the other tested algorithms on more than 45% of them. [5] Initial reference state and counter width can differ across implementations, so a comparison needs these settings as well as capacity and request order.
Approximate recency does not make CLOCK identical to exact LRU. In the published three-slot, empty-cache replay with immediate fills and CLOCK init_freq=0, n_bit_counter=1, AABCDA gives CLOCK two hits and LRU one; AABCDB reverses that result. These are constructed traces, not timing measurements. [2]
DULO's simulation uses CLOCK while labelling it LRU; that baseline must be distinguished from exact-LRU replay and from its separate Linux prototype. [7]
This bit-only rule describes cache eviction; the 1981 virtual-memory formulation also defers replacement of dirty victims until cleaning. [6]
Relations
- related
- SIEVE cache eviction, Least recently used replacement, Adaptive Replacement Cache, Cache pollution, CLOCK-Pro, CAR (CLOCK with Adaptive Replacement), Wise Ordering for Writes, WSClock, DULO, LeanStore
Advantages
- A hit costs only setting a bit, and in virtual memory the hardware can set it. [3]
Limitations
- Long scans can displace reusable entries; scan resistance requires more than basic second-chance replacement. [3, 4]
- A single reference bit cannot distinguish one recent access from many, so frequency is ignored. [3]
- Miss handling can take longer when the hand has to clear many set bits before it finds a victim. [3]
Citations
- Hesela: explicit CLOCK settings and complete constructed-trace hit/miss outcomes.
- Bansal and Modha. CAR: Clock with Adaptive Replacement. USENIX FAST 2004, sections I-II.
- Jiang, Chen and Zhang. CLOCK-Pro: An Effective Improvement of the CLOCK Replacement. USENIX Annual Technical Conference 2005, sections 1-2.
- Zhang, Yang, Yue, Vigfusson and Rashmi. SIEVE is Simpler than LRU: an Efficient Turn-Key Eviction Algorithm for Web Caches. USENIX NSDI 2024.
- Richard W. Carr and John L. Hennessy. WSClock - A Simple and Effective Algorithm for Virtual Memory Management. SOSP 1981, pp. 87-95.
- Jiang et al. DULO: An Effective Buffer Cache Management Scheme to Exploit Both Temporal and Spatial Locality. FAST 2005, sections 3, 4.1.1, 4.2.2.
Further reading
Sources & caveats
- car2004 is the FAST 2004 paper on CLOCK with adaptive replacement, read in sections I and II for the CLOCK description, its origin and its weaknesses.
- clockpro2005 is the USENIX 2005 paper on an improved CLOCK, read in sections 1 and 2 for the hand and reference-bit mechanism and its relation to LRU.
- sieve2024 is the NSDI 2024 paper, read for the equivalence of CLOCK variants, the retained-object position and the trace evaluation.
- The ghost-cache-entry entry links here because improved CLOCK variants add records of recently evicted pages to the basic clock.
- 2026-10-24: qualified the hit-path lock claim; CAR sections I.B-I.C discuss recency-list contention, not a universal lock-free cache guarantee. CLOCK-Pro is indexed separately.