# LHD's terminal age bucket

The pinned simulator gives its lowest rank to a candidate in the last age bucket,
even when the overflow counter stays zero. This is a boundary diagnostic, not a
claim that LHD's measured cache hit ratios are wrong.

## Reproduce

Download [probe.py](probe.py), [test_probe.py](test_probe.py), [lhd.hpp](lhd.hpp),
[LICENSE](LICENSE), [results.json](results.json) and this README.md. Python 3 and a C++17 compiler named
c++ are sufficient. No workload download or third-party Python package is needed.

```sh
python3 -B probe.py --check
python3 -B -m unittest discover -s . -p test_probe.py -v
```

The probe verifies SHA-256 hashes of the complete upstream header and license,
extracts unchanged getAge/getHitDensity bodies, and compiles them inside a small
fixture. The fixture supplies a class density; it does not execute classification,
learning, age adaptation, admission, random victim selection or cache requests.
Tests compare native output with an independent integer-threshold oracle and
compare optimization levels O0 and O2. Binaries exist only in temporary directories.

## Interpret the boundary

With H = MAX_AGE = 20000 and fixed shift s, the coarsened age is floor(age/2^s).
getAge increments overflows only at age >= H * 2^s. getHitDensity returns the
lowest float already at age >= (H - 1) * 2^s, before looking up a learned score
or applying the explorer bonus. Consequently a whole bucket, 2^s accesses wide,
has terminal priority without an increment to overflows.

At the header's initial shift 10 these thresholds are 20,478,976 and 20,480,000
accesses. They are not durations in seconds or fixed thresholds throughout a run:
the simulator can adapt the shift. A rank is not an eviction event. A candidate
must be evaluated by the victim-selection path, and ties still require selection.

Calling the rank function three times for the same over-age object increments
the counter three times. The counter therefore does not count unique objects,
evictions or lost hits. Zero overflows does not prove absence of terminal ranks.

The supplied class score 50 and size 100 yield rank 0.5, or 1.5 for an explorer,
before the boundary. These are chosen inputs, not learned predictions. The last
bucket instead returns the lowest finite float, not minus infinity. A terminal
rank is a policy sentinel, not a physically meaningful negative hit density.

## Sources and limits

- Beckmann, Chen and Cidon, *LHD: Improving Cache Hit Rate by Maximizing Hit Density*,
  NSDI 2018, pp. 389-403. Section 3.5 describes explorers retained until a large age;
  Appendix A explains age coarsening and the finite horizon.
  https://www.usenix.org/system/files/conference/nsdi18/nsdi18-beckmann.pdf
- Author simulator commit 806ef466160c5e968efcc60d1e6476ab802f7f55, lhd.hpp
  lines 142-157; lhd.cpp rank(), update() and adaptAgeCoarsening().
  https://github.com/CMU-CORGI/LHD/tree/806ef466160c5e968efcc60d1e6476ab802f7f55
- Header SHA-256: 8145374086d205fddb9c5a489fe84d9578e508e5190b53fe79085dc412bd50dd.
- Sources accessed 2026-11-28. The upstream header is distributed with its original
  copyright and permission notice in LICENSE. Probe and tests are Hesela's fixture.

This reproduces two specific published code paths, not the entire simulator or
RankCache. It does not measure how frequently the boundary is reached in real
traces, prove a performance regression, or establish a bug in the paper's results.
