{
  "slug": "fifo-replacement",
  "term": "First-in first-out cache replacement",
  "aliases": [
    "FIFO replacement"
  ],
  "definition": "First-in first-out cache replacement evicts the resident entry that was inserted earliest, without refreshing its queue position on a hit.",
  "note": "This policy concerns eviction, not scheduling or write durability. A larger FIFO cache can have more misses on the same reference string. The unbounded anomaly result varies capacities and reference strings; it is not an unbounded ratio at fixed capacities. [fifo-unbounded]\n\nA ring buffer can avoid per-object pointers. Plain FIFO needs no queue-order update on a hit, but lookup, lifetime and synchronization work remain. Locked hit promotion is a shared-list implementation, not a requirement of every LRU implementation. [s3fifo] [qdlp]\n\nLazy promotion defers movement until eviction; quick demotion removes unpromising new objects early. These variants are not plain FIFO. [qdlp]\n\nS3-FIFO uses small, main and ghost queues. Its paper policy caps frequency at three. Small-queue promotion uses frequency > 1, requiring two cache hits after insertion; movement clears the counter. Main-queue reinsertion uses frequency > 0 and decrements it. A single hit qualifies for main reinsertion but not small-queue promotion. [s3fifo]\n\nGhost history is not cached payload. A match remains a cache miss; fetched data goes directly to the main queue. A main-queue eviction does not add its victim to G. [s3fifo]\n\nFor N main-queue entries with counters at most three and no concurrent hits, insertions, expiration or resizing, an eviction takes at most 3N + 1 candidate inspections. Each reinsertion spends one counter credit; the final inspection removes a zero-counter entry. This is policy work, not elapsed time. [s3fifo-example] [s3fifo-method]\n\nFlash friendliness does not guarantee zero amplification. Here cache-level rewriting, device-level garbage collection and admission filtering are separate; queue order alone does not establish NAND write volume. [flashield]",
  "related": [
    "belady-anomaly",
    "cache-inclusion-property",
    "lru-replacement",
    "clock-replacement",
    "sieve-eviction",
    "s3-fifo",
    "flashield",
    "first-come-first-served"
  ],
  "citations": [
    {
      "id": "fifo-unbounded",
      "title": "Peter Fornai and Antal Ivanyi. FIFO anomaly is unbounded. Acta Univ. Sapientiae, Informatica 2(1), 2010, pp. 80-89; sections 2-5, arXiv:1003.1336v2.",
      "url": "https://arxiv.org/pdf/1003.1336v2",
      "accessed": "2026-10-26"
    },
    {
      "id": "hesela",
      "title": "Hesela: finite cache-capacity replay, with full traces and assumptions.",
      "url": "https://hesela.com/analyses/sieve-cache-eviction-traces/#capacity",
      "accessed": "2026-10-17"
    },
    {
      "id": "s3fifo",
      "title": "Yang, Zhang, Qiu, Yue and Rashmi. FIFO Queues are All You Need for Cache Eviction. SOSP 2023",
      "url": "https://jasony.me/publication/sosp23-s3fifo.pdf",
      "accessed": "2026-11-05"
    },
    {
      "id": "qdlp",
      "title": "Yang, Qiu, Zhang, Yue and Rashmi. FIFO can be Better than LRU: the Power of Lazy Promotion and Quick Demotion. HotOS 2023",
      "url": "https://jasony.me/publication/hotos23-qdlp.pdf",
      "accessed": "2026-11-05"
    },
    {
      "id": "flashield",
      "title": "Eisenman et al. Flashield: a Hybrid Key-value Cache that Controls Flash Write Amplification. NSDI 2019, pp. 65-78; sections 2.1-2.2.",
      "url": "https://www.usenix.org/system/files/nsdi19-eisenman.pdf",
      "accessed": "2026-10-26"
    },
    {
      "id": "s3fifo-artifact",
      "title": "SOSP 2023 author artifact, S3FIFO.c: default threshold, find and main-eviction paths; pinned commit 6bc49d9630572721b41cd08adfa982775f3cb1de.",
      "url": "https://github.com/Thesys-lab/sosp23-s3fifo/blob/6bc49d9630572721b41cd08adfa982775f3cb1de/libCacheSim/libCacheSim/cache/eviction/S3FIFO.c",
      "accessed": "2026-11-05"
    },
    {
      "id": "s3fifo-metadata",
      "title": "SOSP 2023 author artifact, cacheObj.h: S3FIFO_obj_metadata_t at the same pinned commit.",
      "url": "https://github.com/Thesys-lab/sosp23-s3fifo/blob/6bc49d9630572721b41cd08adfa982775f3cb1de/libCacheSim/libCacheSim/include/libCacheSim/cacheObj.h",
      "accessed": "2026-11-05"
    },
    {
      "id": "s3fifo-example",
      "title": "Hesela: isolated S3-FIFO transition examples, assumptions and executable code; constructed, not a device or trace benchmark.",
      "url": "https://hesela.dev/research/s3fifo-transitions.json",
      "accessed": "2026-10-31"
    },
    {
      "id": "s3fifo-method",
      "title": "Hesela: S3-FIFO transition method, finite-work proof and reproduction instructions.",
      "url": "https://hesela.dev/research/s3fifo-method.md",
      "accessed": "2026-11-05"
    }
  ],
  "status": "research",
  "advantages": [
    {
      "text": "No hit-time queue reordering is required by plain FIFO; this is a narrower benefit than eliminating all flash rewriting.",
      "citationIds": [
        "qdlp",
        "flashield"
      ]
    },
    {
      "text": "The SOSP 2023 CacheLib prototype reported over six times the optimized LRU throughput at 16 threads on a synthetic Zipf workload (alpha = 1.0), not a universal FIFO speedup. Its request count and object population scale with thread count; the curve is not a fixed-working-set speedup.",
      "citationIds": [
        "s3fifo"
      ]
    }
  ],
  "limitations": [
    {
      "text": "When most objects are requested exactly twice and the second request comes after the object leaves a small probationary queue, a partitioned FIFO design misses where plain FIFO or LRU could hit.",
      "citationIds": [
        "s3fifo"
      ]
    },
    {
      "text": "The paper's request-miss-ratio simulations usually ignore object sizes and exclude policy metadata from capacity; byte-miss evaluation uses byte-weighted footprint instead. Equal nominal capacity here is not an equal total-memory-budget comparison.",
      "citationIds": [
        "s3fifo"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-19",
  "provenance": [
    "Fornai and Ivanyi (2010), sections 4-5, Main Theorem and fixed-capacity qualification, rechecked 2026-10-25; the unboundedness quantifier ranges over capacities and reference strings.",
    "SOSP 2023 DOI 10.1145/3600006.3613147, sections 4, 5.1, 5.3 and 5.4, reviewed 2026-10-25. Miss-ratio traces, synthetic throughput and flash-admission experiments are separate evaluations.",
    "HotOS 2023 DOI 10.1145/3593856.3595887, sections 2-3 and Figure 2, reviewed 2026-10-25. Its flash-friendly motivation is not treated as a device-wide zero-amplification theorem.",
    "Flashield sections 2.1-2.2 supply the cache/device write-layer distinction. Source synthesis only: no new throughput or NAND measurement and no reproduction of the papers' benchmarks.",
    "SOSP 2023 section 5.3 specifies one million 4 KB objects and 100 million requests per thread; the scaling qualification was checked against that workload definition on 2026-10-25.",
    "SOSP 2023 section 5.4 and Figure 9 reread on 2026-10-26: flash size is relative to unique trace bytes; DRAM fractions are relative to flash capacity. These are distinct from section 4's small/main resident partition.",
    "Rechecked 2026-11-05: section 4.1 explicitly clears access bits on small-to-main movement; that reset is not shown in Algorithm 1's promotion branch. The isolated example follows the prose, not a literal execution of every pseudocode line. [s3fifo]",
    "The HotOS study tested 5307 traces; not every trace favored FIFO-Reinsertion over LRU, and results varied with capacity and workload. [qdlp]",
    "S3-FIFO's evaluated default gives 10% of resident space to the small queue, 90% to main, and ghost metadata for as many entries as main. Its miss-ratio evaluation uses 6594 traces from 14 datasets. [s3fifo]",
    "The flash-admission comparison uses 10% of the trace footprint in bytes for flash, with DRAM at 0.1%, 1% or 10% of flash capacity. These are tier-capacity denominators, not the resident queue split. [s3fifo]",
    "The pinned author simulator increments a 64-bit frequency field on hits and clips it during main-queue reinsertion. Two policy bits are not a measurement of total metadata. Source inspection, not execution of that simulator. [s3fifo-artifact] [s3fifo-metadata]",
    "SOSP 2023 section 4.1/Algorithm 1, pp. 134-135, and section 5.1, pp. 136-137, reread 2026-10-31. Pinned find/insert/eviction paths corroborate routing. The example is not an admission simulator. [s3fifo] [s3fifo-artifact]"
  ]
}
