Mehdi Akiki

Posts tagged "when the benchmark lies"

  • Published on

    Investigation · Part 5 of 20 · When the benchmark lies

    JIT Warmup: Why a Function Gets Faster After Thousands of Calls

    A small Java function took 66 ns per call in the first batch and 3.6 ns after 185 batches. I matched the speed changes with the JIT compile log, compared C1 and C2, and looked at why the steady state was not one number.
  • Published on

    Investigation · Part 4 of 20 · When the benchmark lies

    Why the First Run Is Slower

    The first iteration of my loop took 145 microseconds and the steady state 12. I separated the causes I could show on my laptop: page faults, cold caches, a pause of 300 ms, lazy binding in C, and the start of the process itself.
  • Published on

    Investigation · Part 3 of 20 · When the benchmark lies

    When the Compiler Computes the Answer Before the Benchmark Runs

    On my laptop, summing the numbers below one thousand takes 0.81 ns, and below one billion also 0.81 ns. black_box hid the value of n, but LLVM replaced the loop with a formula. I show the assembly, the IR, the LLVM pass, and a benchmark that really grows with n.
  • Published on

    Investigation · Part 2 of 20 · When the benchmark lies

    A Debug Build Measures a Different Program

    A test called score_is_fast measured 44,646 ns per call under cargo test and 1,136 ns with --release, one run each. I compare four optimization levels in Rust and two in C, and I show in the assembly what a debug build really measures.
  • Published on

    Investigation · Part 1 of 20 · When the benchmark lies

    The Benchmark That Measured Nothing

    My first benchmark said that my laptop adds 4,096 numbers in 0.00005 nanoseconds. The compiler had deleted the loop. I show it in the assembly, fix it with black_box, make the same mistake in C, and explain the method of this series.