{
  "slug": "clock-replacement",
  "term": "CLOCK cache replacement",
  "aliases": [
    "CLOCK",
    "second-chance replacement",
    "FIFO reinsertion"
  ],
  "definition": "CLOCK is a cache replacement policy that gives referenced entries another chance by clearing their reference state during an eviction scan.",
  "note": "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. [car2004] Dating from 1968, it approximates LRU but remains scan-vulnerable. [car2004] [clockpro2005]\n\nSecond 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. [sieve2024] Initial reference state and counter width can differ across implementations, so a comparison needs these settings as well as capacity and request order.\n\nApproximate 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. [replay]\n\nDULO's simulation uses CLOCK while labelling it LRU; that baseline must be distinguished from exact-LRU replay and from its separate Linux prototype. [dulo2005]\n\nThis bit-only rule describes cache eviction; the 1981 virtual-memory formulation also defers replacement of dirty victims until cleaning. [wsclock1981]",
  "related": [
    "sieve-eviction",
    "lru-replacement",
    "adaptive-replacement-cache",
    "cache-pollution",
    "clock-pro",
    "car-replacement",
    "wise-ordering-for-writes",
    "wsclock",
    "dulo",
    "leanstore"
  ],
  "citations": [
    {
      "id": "authors",
      "title": "Yang and colleagues. SIEVE: Cache eviction can be simple, effective, and scalable. USENIX ;login:, 16 June 2024. Author explanation of list ordering.",
      "url": "https://www.usenix.org/publications/loginonline/sieve-cache-eviction-can-be-simple-effective-and-scalable",
      "accessed": "2026-10-17"
    },
    {
      "id": "replay",
      "title": "Hesela: explicit CLOCK settings and complete constructed-trace hit/miss outcomes.",
      "url": "https://hesela.dev/research/sieve-traces.json",
      "accessed": "2026-10-17"
    },
    {
      "id": "car2004",
      "title": "Bansal and Modha. CAR: Clock with Adaptive Replacement. USENIX FAST 2004, sections I-II.",
      "url": "https://www.usenix.org/legacy/events/fast04/tech/full_papers/bansal/bansal.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "clockpro2005",
      "title": "Jiang, Chen and Zhang. CLOCK-Pro: An Effective Improvement of the CLOCK Replacement. USENIX Annual Technical Conference 2005, sections 1-2.",
      "url": "https://www.usenix.org/legacy/event/usenix05/tech/general/full_papers/jiang/jiang.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "sieve2024",
      "title": "Zhang, Yang, Yue, Vigfusson and Rashmi. SIEVE is Simpler than LRU: an Efficient Turn-Key Eviction Algorithm for Web Caches. USENIX NSDI 2024.",
      "url": "https://www.usenix.org/system/files/nsdi24-zhang-yazhuo.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "wsclock1981",
      "title": "Richard W. Carr and John L. Hennessy. WSClock - A Simple and Effective Algorithm for Virtual Memory Management. SOSP 1981, pp. 87-95.",
      "url": "https://cseweb.ucsd.edu/classes/wi19/cse221-a/papers/carr81.pdf",
      "accessed": "2026-10-31"
    },
    {
      "id": "dulo2005",
      "title": "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.",
      "url": "https://www.usenix.org/event/fast05/tech/full_papers/jiang/jiang.pdf",
      "accessed": "2026-10-30"
    }
  ],
  "status": "research",
  "advantages": [
    {
      "text": "A hit costs only setting a bit, and in virtual memory the hardware can set it.",
      "citationIds": [
        "car2004"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Long scans can displace reusable entries; scan resistance requires more than basic second-chance replacement.",
      "citationIds": [
        "car2004",
        "clockpro2005"
      ]
    },
    {
      "text": "A single reference bit cannot distinguish one recent access from many, so frequency is ignored.",
      "citationIds": [
        "car2004"
      ]
    },
    {
      "text": "Miss handling can take longer when the hand has to clear many set bits before it finds a victim.",
      "citationIds": [
        "car2004"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "provenance": [
    "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."
  ]
}
