TactivergeLite

Lite / Engineering Complex Systems / Week 34

Designing a benchmark you can trust

The new version is 1.6× faster. Or the first runs were cold, the laptop was heating up and the test file was smaller. Which?

About 45 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

The term project asks you to prove an optimisation worked. A benchmark is an experiment: it can be fair or rigged, precise or noisy. Most surprising speed-ups in the wild come from methodology, not from the code.

Predict

The checker starts with 5 repeats, no warm-up, blocked order and B on a smaller input. Will the measured speed-up be too high, too low, or about right?

  1. Too high, mainly because B's input is smaller
  2. Too low
  3. About right
  4. It can't be predicted
Guess first, then reveal

The smaller input flatters B a lot. Drift works against B in blocked order (B runs later, when the machine is warmer and slower), and cold starts slow both. The net is an inflated speed-up with a wide interval.

Discover

Fix the problems one at a time and watch the speed-up and its interval after each: same input, then interleaved order, then 3 warm-up runs, then 30 repeats. Which fix moved the estimate most? Which narrowed the interval most? Re-run with new seeds to see the interval jitter.

What the interactive shows (text version)

The checker simulates per-run times for a baseline A (true 40 ms) and version B (true 31 ms on the same input, 24 ms on a smaller one), with cold-start penalties on the first three runs of each version, a slow upward drift over the session, and random noise. It plots runs in order and reports each mean with a 95% interval, the speed-up with its interval, and a checklist: warm-up of at least 3 runs, at least 10 repeats, interleaved order and the same input. Fixing all four gives speed-ups close to the true 1.29.

You can also open the interactive on the full site when you have a faster connection.

Understand

Decide before you measure

Write down the metric (median wall time per run? energy per job?), the workload (input files, sizes), the baseline (current release, built the same way), the environment (machine, power mode, other processes), the number of repeats and the decision rule ('ship if the 95% interval on speed-up is above 1.1'). Deciding afterwards invites choosing whatever looks best.

Warm-up and steady state

First runs pay for empty caches, page faults, JIT compilation and frequency ramp-up. Unless cold-start performance is what you care about (an app's launch time), discard a few warm-up runs and report steady-state. If it is what you care about, measure it deliberately with a fresh process each time.

Repeats and variance

Timing noise comes from interrupts, scheduling, thermal throttling and memory layout. Repeat enough to make the standard error small compared with the effect you care about, and report spread, not just the mean. Medians and percentiles are robust to occasional slow runs; say which you use.

Fair comparison

Same input, same build flags, same machine, same conditions. Interleave versions (A, B, A, B…) or randomise their order so slow drift affects both equally. Pin CPU frequency if you can, close other programs, and note what you couldn't control. A fair benchmark is one where the only systematic difference is the change under test.

Explain it another way

Intuitive

Racing two runners is unfair if one starts cold, one runs downhill, or one runs a shorter track. A benchmark is a race; make the track the same.

Technical

Threats to validity: warm-up effects, order effects (drift, thermal), workload mismatch, compiler flag mismatch, measurement overhead (timer resolution), outliers from OS noise. Mitigations: warm-up discard, interleaving or randomisation, fixed workloads, pinned frequency, many repeats, robust statistics.

Mathematical

With linear drift δ ms per run and blocked order of n runs each, B's mean is biased by about n·δ relative to A. Interleaving reduces this to about δ/2. In the checker, δ = 0.12 ms and n = 13 gives about 1.6 ms of bias blocked, versus 0.06 ms interleaved.

Applied

Industry benchmark suites specify exact workloads, run rules and reporting requirements, so that results from different vendors can be compared, and publish the full disclosure of how each result was obtained.

Worked example 1

Blocked order: A runs first for 13 runs, then B for 13. The machine slows by 0.12 ms per run. Estimate the bias in B's mean.

A's runs occur on average at position 6.5, B's at 19.5: 13 positions later. Bias ≈ 13 × 0.12 = 1.56 ms added to B, making B look slower than it is. Interleaving would cut this to about 0.06 ms.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 1. Why discard the first few runs of a steady-state benchmark?
Practice 2. Why interleave runs of A and B rather than running all A then all B?

×

Practice 5. Which decision rule is best written before running the benchmark?

Apply it

Write a one-page benchmark protocol for your term project: metric, workload, baseline, environment, warm-up, repeats, order, statistics and decision rule. Get a classmate to find one way your protocol could still be unfair.

Reflect

Which threat to fair comparison would be hardest to control on your own computer?

Write your answer on paper or in your own notes. Lite never stores what you write.

Go further

Research mode: limits and open questions

Benchmark results that can't be reproduced are a recognised problem across computing research; artefact evaluation, in which reviewers re-run a paper's experiments from its published code, is one response.

← From source code to running hardware, and testing the joinA speed-up is a ratio: give it an interval →