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

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.
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 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?
-warmup + -runs 50 does NOT solve the problem: it averages, but the alignment remains the same on each run of the same binary.-randomize-address and report a 95% IC, not an average.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.
Create a free account to access all our content and the weekly review.
Article produced by artificial intelligence, reviewed under human editorial control.
Sign in to join the discussion.
Ces variations sont impressionnantes. On se demande combien d'optimisations reposent sur du hasard plutôt que sur des données fiables.
Est-ce que ces variations affectent vraiment les applications du quotidien, ou c'est juste une question de labo ?
Les micro-benchmarks sont vraiment peu fiables. Il faut en tenir compte quand on évalue les performances.
Est-ce qu'il existe des outils pour fiabiliser les micro-benchmarks ?
On a bien fait de le rappeler : les micro-benchmarks sont trompeurs. Il faut les prendre avec des pincettes.
Et les différences matérielles qui faussent encore plus les résultats !
Je croyais aux benchmarks, mais là c'est inquiétant. Comment croire en ces mesures maintenant ?