{
  "slug": "counter-stacks",
  "term": "Counter Stacks",
  "aliases": [
    "counter stack",
    "counter stack stream"
  ],
  "definition": "Counter Stacks estimates LRU miss-ratio curves using compact histories of distinct-block counts over overlapping time intervals.",
  "note": "Mechanism: counters start at different times; finite differences reveal reuse in the ideal exact matrix. The practical method combines downsampling, pruning and HyperLogLog. Its retained stream supports time slicing, shifting and workload combination. [paper]\n\nJoining has a boundary: the paper's addition-based operation assumes disjoint block sets. Counter estimation error is separate from this identity assumption. [paper]\n\nConstructed example: two streams each read their single block twice, interleaved. Each stream reports one distinct block whether their blocks are shared or different. In a one-entry LRU cache, the shared-block merge misses 1/4 requests; the disjoint merge misses 4/4. Adding counts gives two in both cases, which is wrong for the shared union. Counts alone cannot recover the missing overlap information. [example]\n\nWindow example: score only the last AB of ABAB in a two-entry cache. Keeping the preceding AB as warm-up gives 0/2 misses; replaying the last AB from empty gives 2/2. Neither denominator includes warm-up requests. State the initialization separately from the scoring window. [example]\n\nLimits: a compact locality summary is not a lossless trace or a prediction of storage latency. The linked evaluator is a bounded exact teaching model, not practical Counter Stacks, a device benchmark or a replication of the paper's accuracy results. [code]",
  "status": "research",
  "advantages": [],
  "limitations": [],
  "related": [
    "working-set",
    "reuse-distance",
    "miss-ratio-curve"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-18",
  "citations": [
    {
      "id": "paper",
      "title": "Wires, Ingram, Drudi, Harvey and Warfield. Characterizing Storage Workloads with Counter Stacks. OSDI 2014, pp. 335-349, sections 3-6.",
      "url": "https://files.usenix.org/s3fs-public/cdn/osdi14-paper-wires.pdf",
      "accessed": "2026-11-18"
    },
    {
      "id": "venue",
      "title": "USENIX. OSDI 2014 publisher record, authors and proceedings metadata.",
      "url": "https://www.usenix.org/conference/osdi14/technical-sessions/presentation/wires",
      "accessed": "2026-11-18"
    },
    {
      "id": "example",
      "title": "Hesela. Exact synthetic identity and initial-state counterexamples with explicit denominators.",
      "url": "https://hesela.dev/research/counter-stacks/evidence.json",
      "accessed": "2026-11-18"
    },
    {
      "id": "code",
      "title": "Hesela. Bounded exact distinct-count matrix and LRU scoring evaluator.",
      "url": "https://hesela.dev/research/counter-stacks/model.mjs",
      "accessed": "2026-11-18"
    },
    {
      "id": "tests",
      "title": "Hesela. Independent LRU oracle and exhaustive short-trace checks.",
      "url": "https://hesela.dev/research/counter-stacks/model.test.mjs",
      "accessed": "2026-11-18"
    }
  ],
  "provenance": [
    "Source review covers the original method, joining assumption and evaluation limits. The USENIX proceedings identify the October 2014 conference; no invention date is asserted.",
    "Synthetic evidence uses exact integer counts. No author code, MSR traces, probabilistic counters or measured speedup are reproduced."
  ]
}
