Part 3 in Measuring things honestly. Earlier parts: what a benchmark is and why one run is not enough.
What this is about
Run the same program twice on the same computer and the timings will differ. Not by a lot, but they will differ. That small wobble is called noise.
Noise is not a bug in your test. It comes from the computer itself, and you cannot remove it. What you can do is measure it, and keep it from fooling you.
Why it matters
Noise causes two opposite mistakes.
The first mistake is to see a change that is only noise. You flip a setting, the time drops a little, and you celebrate. Run it again and the time comes back up. The setting did nothing.
The second mistake is subtler. You see a very steady number and trust it too much. A steady number only tells you the test is repeatable. It does not tell you the test is looking at the right thing. We learned this the hard way, and we explain how below.
How it works
Where noise comes from
A computer is never doing only one thing. Other programs wake up. The chip changes its clock speed to save power or cool down. Memory is shared. Files get cached. Each of these nudges your timing.
Here is a real example from our own tool corewait. We measured how fast one thread can read memory on our desktop, a Ryzen 7 7800X3D. Over five runs, the answer ranged from 46.0 to 57.7 gigabytes per second, while other sessions were using the machine. That is a spread of more than ten gigabytes per second for one simple test.
How to see the noise
- Run the same test several times, with nothing else changed.
- Write down every result, not only the best.
- Look at the lowest and the highest. The gap is the noise in that test.
How to use what you see
If you compare two versions and the gap between them is smaller than the noise, you cannot say which is faster. If the gap is much bigger than the noise, you probably can. We also alternate the two versions in the same session, so a slow patch on the machine hits both of them. In one of our GPU tests we took turns between the two versions over four rounds for exactly this reason.
The trap a tight spread cannot catch
Here is the part that surprised us.
For about a week, we believed our hand-written matrix multiplication was about twice as fast as AMD's own library on the RX 7900 XTX. The number was reproducible. The spread was tight. It was also wrong.
The mistake was on the other side of the comparison. Our own code that called AMD's library never configured it properly. It set aside new working memory on every call, trusted a default choice of method, and never set two tuning options at all. Once we fixed our own call, the library went from 2497 to 5201 GFLOP/s at one size, and our lead vanished. Choosing the right method alone took it from 3097 to 5201.
Why did the steady number fool us? Because a badly set-up test is consistently badly set up. It does the same wrong thing every time, so it gives the same answer every time. Noise measures how repeatable a test is. It says nothing about whether the test is aimed at the right thing.
It happened again. We needed a baseline with a speed-up feature switched off, so we sent a request asking for zero draft tokens. The server accepted the request without any error. It also ignored the field. The response still showed draft tokens being used. If we had not read that part of the response, our "no speed-up" baseline would have been the sped-up number, and every comparison after it would have been wrong.
Our longer write-up of both cases is Spread Does Not Detect an Inert Parameter. The old rule "discard a round if the spread is over ten percent" was in use the whole time, and it could not have caught either mistake.
A simple habit that helps
Before you trust a measurement, flip the setting you care about and check that something visible changes. If you flip it and nothing moves, either the setting does nothing, or your test cannot see it. Both are worth knowing before you publish.
Read the output of the test too, not just the timing. In the second case above, one line of the server's reply gave the game away.
Glossary
- Noise: small random changes in a measurement from run to run.
- Spread: the gap between the lowest and highest result.
- Reproducible: gives the same answer when repeated.
- Inert: does nothing.
- Arm: one setting in a comparison.
- GFLOP/s: billions of arithmetic operations per second, a measure of calculation speed.
- Baseline: the version you compare against.
Try it
Time any task three times and write down the three results. Then change one setting that should not matter, such as closing a browser window, and time it three more times. Do the two groups of three overlap? If they do, the change is lost in the noise.
If you want to see noise on a real machine, run the memory-speed probe in corewait. It reports sequential read speed for one thread and for all threads, so you can run it several times and watch the spread yourself.
What to remember
Noise is normal. Measure it, and compare gaps against it. And remember that a steady number can still be pointed at the wrong thing.

Comentarii
Niciun comentariu încă.
Conectare pentru a comenta.