"Your code is fast - if you're lucky": why your micro-benchmarks lie

CraftSubscribers only Jul 11, 2026 at 17:146Add to bookmarks

"Your code is fast - if you're lucky": why your micro-benchmarks lie
Illustration : Léa Fontaine

A viral post questions the reliability of micro-benchmarks: the same code can vary by 30% depending on the order of symbols, memory position, or username. What this means for craft.

In plain terms

A developer has shown that a piece of code can be 30% faster or slower depending on parameters unrelated to the algorithm: symbol order at link-time, environment variable size, memory alignment. In other words, a good part of what we measure in microseconds is down to luck.

The story

The author, on tiki.li/blog/lucky_code, revisits a well-known thread among compilers (Emery Berger, Stabilizer, ASPLOS 2013) and brings it up to date: they execute the same binary, without modifying it, and vary peripheral parameters (build directory name, object file link order, $PATH size). The runtimes move significantly, up to more than 30% on micro-benchmarks. The cause: the alignment of instructions in the L1i/uop caches, the x86 decoder, and branch prediction, which are sensitive to the virtual address of the code.

The point that should disturb everyone: in real life, we compare a PR before/after, note a gain of 8%, and merge. How much of these gains are real signal? How much is alignment noise?

Under the hood

  • Stabilizer (Berger 2013) randomizes stack, heap, and code allocation on each run - measurements become distributions, not points.
  • Hyperfine + -warmup + -runs 50 does NOT solve the problem: it averages, but the alignment remains the same on each run of the same binary.
  • The good practice: recompile with random offsets (Stabilizer, or manual padding) OR execute with -randomize-address and report a 95% IC, not an average.

So what

Three consequences for the craft. One: any performance gain under 10% on a single micro-benchmark is probably noise. Reject it, or redo it under randomization. Two: CI performance regressions (like Codspeed) must adopt randomization, otherwise we will let real regressions pass and panic over noise. Three: compiler and runtime marketing benchmarks (Bun vs Node, Zig vs C…) should be read with this filter. Performance, at this level, is as much about build engineering as it is about the algorithm.

Content reserved for members

Create a free account to access all our content and the weekly review.

Article produced by artificial intelligence, reviewed under human editorial control.

Our newsroom
Your Linux servers, as a desktop.
TermalOSSponsored
Ops, reimagined

Your Linux servers, as a desktop.

Agentless SSH monitoring, a full remote desktop and an AI ops copilot — no agents to install. Everything stays on your machine.

SSHMonitoringAI Ops
Get early access
Was this article helpful?

9 people liked this article

Like
M
Mateo RossiSoftware architect
🇬🇧 Architect, two decades of production systems.
Share:
Comments (6)

Sign in to join the discussion.

Alex 11 Jul 2026 · 17:55

Ces variations sont impressionnantes. On se demande combien d'optimisations reposent sur du hasard plutôt que sur des données fiables.

1
Alex_London 11 Jul 2026 · 17:35

Est-ce que ces variations affectent vraiment les applications du quotidien, ou c'est juste une question de labo ?

ArtLover88 11 Jul 2026 · 16:50

Les micro-benchmarks sont vraiment peu fiables. Il faut en tenir compte quand on évalue les performances.

SkepticSam 11 Jul 2026 · 16:07

Est-ce qu'il existe des outils pour fiabiliser les micro-benchmarks ?

HistoryBuff 11 Jul 2026 · 15:55

On a bien fait de le rappeler : les micro-benchmarks sont trompeurs. Il faut les prendre avec des pincettes.

TechSavvy 11 Jul 2026 · 18:32

Et les différences matérielles qui faussent encore plus les résultats !

Dr. J. 11 Jul 2026 · 15:20

Je croyais aux benchmarks, mais là c'est inquiétant. Comment croire en ces mesures maintenant ?

Your Linux servers, as a desktop.
TermalOSSponsored
Ops, reimagined

Your Linux servers, as a desktop.

Agentless SSH monitoring, a full remote desktop and an AI ops copilot — no agents to install. Everything stays on your machine.

Get early access
Topics
Explore
Information