# A larger upper LRU cache can increase backend reads

This is an exact constructed counterexample, not measured device behavior,
a reproduction of the MQ benchmark, or a claim of first discovery.

## Contract and result

Two independently managed, initially empty, fully associative LRU read caches
process ABCABDEA. Objects have equal size; capacity is measured in object slots.
Every upper miss sends exactly one request down; every lower miss reads the
backend. Data is admitted on every miss. Upper hits do not update lower recency.
There are no back-invalidations, victim transfers, pins, writes, TTLs, prefetch,
coherence, concurrent requests, bypass or block splitting. This is not an
inclusion-enforced processor-cache model.

| Upper / lower slots | Upper hits / 8 | Lower hits / lookups | Backend reads / 8 |
| --- | --- | --- | --- |
| 2 / 4 | 0 / 8 | 3 / 8 | 5 / 8 |
| 3 / 4 | 2 / 8 | 0 / 6 | 6 / 8 |

At three upper slots, requests 4 and 5 hit above. Lower LRU sees ABCDEA,
not ABCABDEA, and A remains its oldest entry until E evicts it. A has also
left the upper cache before request 8. With two upper slots, requests 4 and 5
refresh A and B below, so E evicts C instead and final A hits below.

The larger upper cache saves two lower lookups but causes one additional backend
read. The total number of cache-served application requests changes from 3 to 2.
No latency conclusion follows without costs for the distinct operations.

Demand LRU inclusion compares capacities on the SAME reference sequence.
The lower sequences here differ. Each individual LRU cache still obeys its
own stack property. At five lower slots both hierarchies read the backend five
times; the effect is not inevitable. On the unchanged application trace, a
single LRU with 2, 3, 4, 5 slots has 8, 6, 5, 5 misses.

## Reproduce

Use Node.js with no installed dependencies:

```sh
node model.mjs --check
node --test model.test.mjs
```

evidence.json contains every request, service source and resident order, plus
both controls. Regenerate it using node model.mjs --write. All counts are exact
integers. No statistical confidence interval is applicable to this fixed trace.

An independent history-suffix oracle reconstructs each resident set from the
most recent distinct references. It agrees with the mutable Map implementation
in 39,360 trace/capacity configurations: all 3,280 ternary traces of lengths 0
through 7, upper capacities 1-3 and lower capacities 1-4. The five-identity
published trace is checked separately. This is bounded validation, not a proof
for all workloads. No shortest-counterexample claim is made.

## Primary-source context

Zhou, Philbin and Li, *The Multi-Queue Replacement Algorithm for Second Level
Buffer Caches*, USENIX ATC 2001, pp. 91-104:
[trace collection](https://www.usenix.org/legacy/event/usenix01/full_papers/zhou/zhou_html/node4.html)
and [temporal locality](https://www.usenix.org/legacy/event/usenix01/full_papers/zhou/zhou_html/node6.html).
Their lower-level streams are filtered by upper caches. Their Oracle captures
fix duration rather than completed transaction count, so the two captures are
not one unchanged application trace. Our example does fix that trace.

Frigo, Leiserson, Prokop and Ramachandran, *Cache-Oblivious Algorithms*,
FOCS 1999 extended abstract, section 6 and Lemma 14:
[full text](https://www.cs.cornell.edu/courses/cs612/2006sp/papers/frigo99.pdf).
Its multilevel LRU model protects entries resident above from lower eviction.
That cross-level mechanism is absent here; the counterexample does not refute
the paper's result.

Sources accessed 2026-11-19. The algorithm is our explicitly specified teaching
model, not copied author code. Code and generated data: MIT license. Paper
copyrights remain with their owners; no paper or figure is redistributed.
