Keep the starting state visible

A costs 6 units and B costs 8 before cache misses. A has the lower cost when both start cold, and when both start warm. Run A first against one shared cold cache, however, and the recorded costs become A 16 and B 8. Reverse the order and they become A 6 and B 18. The implementation costs have not changed; the starting states have.[3][4]

These are invented cost units from a tiny deterministic Python model, not measured durations. Both implementations use the same workload key. A miss adds 10 units and inserts that key into a shared set. A hit adds nothing. The model has no eviction, capacity limit, concurrency or invalidation. Every comparison arm starts with a declared reset.[4][3]

  • Name the starting state: Declare reset, warmup, shared-key scope and invocation order before interpreting a comparison.

Compare the declared cache states

The independent cold arm resets before each invocation. A pays 6 plus 10, and B pays 8 plus 10. The independent warm arm resets and prewarms before each invocation, so the recorded invocation costs are 6 and 8. Both comparisons favor A, but they describe different starting states.[3][4]

The shared arms reset only before the pair. In A-then-B order, A pays the miss and leaves a hit for B. In B-then-A order, B pays the miss and leaves a hit for A. Reporting only one order would mix implementation identity with cache position. The complete artifact retains both rows in both orders, including each cache transition.[3][4]

Four authored arms, two invocations each. All values are invented cost units. The A and B columns compare invocation costs only.

State / orderABSetup totalFull-model total
Independent cold1618034
Independent warm682034
Shared A then B168024
Shared B then A618024
  • Full-model total = setup + both invocation costs. Each arm starts reset; the independent arms also reset before each invocation.
  • Equal-order mixture reuses the four shared rows: mean A 11, mean B 13, B/A = 13/11. It creates no new invocation.

Retain setup and the comparison window

Warmup does not disappear from the accounting. Each prewarm costs 10 invented units outside the invocation comparison. The independent warm arm therefore has 20 setup units plus 14 invocation units, for a full-model total of 34. The cold arm also totals 34. This equality follows from the authored assumptions; it is not a measurement of real warmup or reset overhead. Reset is assigned zero cost only inside this model.[3][4]

An explicitly balanced comparison reuses the four shared-arm records. A averages (16 + 6) / 2 = 11 units, and B averages (8 + 18) / 2 = 13. The ratio of those means is 13/11. This is one cold and one warm observation per implementation, with equal weight on the two orders. It is a defined mixture, not a universal estimate of steady-state performance or a reason to average every experiment.[3][4]

Ten authored checks cover population retention, transitions, cost conservation, mixture arithmetic and selected malformed inputs. Twelve separate conditional-control invocations show the limits: removing the miss penalty, giving the implementations different keys, or prewarming the shared key removes this order effect. The prewarmed controls still retain their setup cost. None of these rows estimates how often real benchmarks encounter the problem.[3][4]

  • Keep setup visible: An invocation window can exclude warmup while the full-model ledger still retains its cost.

Keep order with the evidence

Google Benchmark documents warmup and random interleaving, and PyTorch Timer documents warmups for lazy initialization. These are useful reasons to state a benchmark’s initialization and ordering policy. They do not validate the invented values here. This proof executes only the Python standard library.[1][2][5]

Before comparing two implementations, name the state you want to compare: cold calls, warm calls, a sequential workload, or a declared mixture. Retain order and setup alongside the results. A change in the winner can be a change in the question, rather than a change in the implementation.[4][5]

  • Compare the declared cache states, and retain the setup ledger with the invocation results.

Sources

  1. Google Benchmark User Guide google.github.io
  2. PyTorch2.15 Benchmark Utils — Timer docs.pytorch.org
  3. Complete retained original output data.nodus-compute.ai
  4. MIT source, fixture and protocol data.nodus-compute.ai
  5. Source and saved-result provenance data.nodus-compute.ai
  6. Vector figure data.nodus-compute.ai