# 3L-Cache: pair the experiment before dividing
Review date: 2026-11-25. Tracking: Hesela issue #7632.

The new glossary record documents 3L-Cache. The existing cache analysis adds
an artifact-reproduction caution, not another performance ranking.

## Scope of the source review
Paper: Wenbin Zhou, Zhixiong Niu, Yongqiang Xiong, Juan Fang and Qian Wang,
3L-Cache: Low Overhead and Precise Learning-based Eviction Policy for Caches,
FAST 2025, pages 237-254.
https://www.usenix.org/conference/fast25/presentation/zhou-wenbin
https://www.usenix.org/system/files/fast25-zhou-wenbin.pdf
Relevant sections: 4.2-4.4, 5.1, 5.2.2-5.2.3 and 5.3-5.6.
No DOI is asserted. The conference entry supplies ISBN 978-1-939133-45-8.

The code review pins optiq-lab/3L-Cache at:
134cd159b635cdab75419a4281bed1a330fef31f
The source manifest records exact fetched bytes. Upstream is GPL-3.0; its
files are referenced rather than redistributed in this packet. No claim is
made that this later revision generated the conference figures.

## Reproduced artifact behavior
The reviewed cpu_overhead_boxplot.py converts its baseline vector to N by 1
but leaves the algorithm vector at N elements. Division broadcasts across
traces. Its panel loop also supplies small_cache_sizes twice.
https://github.com/optiq-lab/3L-Cache/blob/134cd159b635cdab75419a4281bed1a330fef31f/3LCache/scripts/cpu_overhead_boxplot.py

audit_source.py checks the exact source SHA-256 before selecting two AST
fragments: the arithmetic loop and capacity-panel dispatch. It does not import
or run the upstream module, its process launchers, model, or plotting library.
A minimal table adapter supplies NumPy arrays; this is not a pandas replay.
The panel collector and plotting function are recording test doubles.

Two synthetic traces have baseline throughputs 10 and 100 requests/s and
candidate throughputs 5 and 25 requests/s. The isolated arithmetic produces
[[2, 0.4], [20, 4]], flattened mean 6.6, instead of paired ratios [2, 4],
mean 3. This is an exact constructed counterexample, not measured slowdown.
The synthetic large-capacity data instead give [1, 2], mean 1.5. Keeping the
same input for both panels would conceal that difference.

NumPy broadcasting rules:
https://numpy.org/doc/stable/user/basics.broadcasting.html

## Corrected comparison
ratios.py matches trace identifier, exact cache bytes, objective and number of
requests before dividing. Duplicate identities, mismatched cohorts, zero or
negative rates and non-finite input fail closed. Counts are integers; rates
accept exact integer or decimal-string input. Fraction arithmetic avoids
rounding the reference result. Missing traces are not silently omitted.

The ratio Q_baseline / Q_candidate equals T_candidate / T_baseline only for
the same amount of completed work. It is not CPU time. With average CPU usage
U, CPU-time ratio also needs U_candidate / U_baseline. Nor is the unweighted
mean of per-trace ratios a pooled CPU cost or a request-weighted result.
A CPU benchmark must retain its measurement boundary and utilization evidence.

AGGREGATION.md derives the baseline-time weights for a serial suite and supplies
a new ranking counterexample. aggregation.json and test_aggregation.py make it
reproducible. mean_ratio now validates a fixed-byte, single-objective panel,
including consistency between rates and the derived ratio; it no longer silently
summarizes mixed capacities. summarize_panel additionally accepts an explicit
capacity_by_trace map; aggregation.py uses that path for a preselected cohort.
The earlier examples and source audit are unchanged.

The fix here is an independent, small pairing helper plus checked publication
data. Upstream files are unchanged. Original trace outcomes and paper figures
have not been recomputed, so their numerical validity is not decided here.

## What does the average answer?
For trace i, let n_i be completed requests and B_i, C_i be whole-run throughput
in requests per second. The durations are b_i = n_i/B_i and c_i = n_i/C_i.
The paired elapsed ratio is r_i = c_i/b_i = B_i/C_i. The equal-trace mean
sum(r_i)/k gives every trace the same weight. In contrast:

    R = sum(c_i) / sum(b_i) = sum(w_i * r_i)
    w_i = b_i / sum(b_i)

This weights by baseline elapsed time, not by request count alone.
For the existing small panel, baseline times are 100 and 10 seconds, while
candidate times are 200 and 40 seconds: R = 240/110 = 24/11, not 3.
The large panel gives 120/110 = 12/11, not 3/2.

The additional direction-reversal case uses 1,000 requests per trace, baseline
rates 10 and 1,000 requests/s, and candidate rates 20 and 100 requests/s.
Paired ratios are 1/2 and 10; the equal-trace mean is 21/4. Yet summed times
are 101 seconds for the baseline and 60 seconds for the candidate, so R is
60/101. The summaries answer different questions; neither is an error merely
because they differ. Equal request counts do not make their weights equivalent.
These are constructed arithmetic examples, not new 3L-Cache measurements.

aggregation.py reports both summaries, exact per-trace durations and weights.
It requires one objective and one selected experiment per trace. Capacities
may differ between traces (for example a preselected footprint-relative panel)
but must match within each pair. Select a panel before calling the helper;
it cannot verify that the selection is scientifically appropriate.
The earlier pairing fixture and source replay are unchanged.

The sum is accumulated per-run elapsed time. It is the elapsed time of a
sequential batch only if those runs compose without omitted overhead or
changes in conditions. It is not the wall-clock completion time of concurrent
runs. CPU accounting instead needs compatible measured CPU seconds, or mean
CPU usage with matching normalization and boundaries for each run.

A matching label and request count do not establish equivalent experiments.
Retain trace-byte identity, request order and timed prefix, warm-up exclusions,
software revision, machine, concurrency and repeat/seed metadata separately.
Throughput here must mean completed requests divided by elapsed time over that
same work, not an arithmetic mean of interval rates. The small helper validates
only its declared keys and positive rates; it cannot verify these external facts.
Exact arithmetic on rounded reported rates does not recover exact timings.
No statistical uncertainty is inferred from these synthetic inputs.
Partitioning a trace at unchanged rates preserves summed durations and their
ratio but can change the equal-trace mean by changing its chosen unit of analysis.

## Reproduce
Requires Python 3. No dependencies for the corrected arithmetic:
```sh
python3 -B -m unittest discover -s . -p 'test_*.py'
python3 -B ratios.py
python3 -B aggregation.py
```

Optional source arithmetic replay requires NumPy and the exact pinned source:
```sh
curl -fL https://raw.githubusercontent.com/optiq-lab/3L-Cache/134cd159b635cdab75419a4281bed1a330fef31f/3LCache/scripts/cpu_overhead_boxplot.py -o author_cpu_overhead_boxplot.py
python3 -B audit_source.py author_cpu_overhead_boxplot.py
```
Do not run the upstream script itself as part of this check. Changed sources
must undergo another review, not a checksum update to force acceptance.

examples.json contains the original synthetic pairing fixture and corrected results.
aggregation.json adds exact weighting results and the direction-reversal fixture.
source-audit.json records the isolated arithmetic output and runtime.
No real traces, benchmark timings or confidence intervals are invented.

## CPU measurement boundary

CPU_ACCOUNTING.md relates the paper's load-times-time definition to measured
process counters. cpu_accounting.py and cpu-examples.json compare exact
counter costs separately from elapsed-time ratios. probe_cpu_scope.py and
cpu-observation.json retain three actual parent/worker accounting observations.
These observations are not cache benchmarks or a replication of the paper.

## Unequal CPU sampling intervals

CPU_SAMPLING.md derives duration-weighted usage from contiguous cumulative
counter intervals. cpu_intervals.py and test_cpu_intervals.py reproduce the
constructed four-versus-twenty CPU-second example and its repartition control.
cpu-interval-examples.json is generated arithmetic, not another native probe.
The earlier CPU-accounting observation and artifact-replay evidence are unchanged.
