Mehdi Akiki

Writing archive

Everything published under Writing, newest first. Each entry is labelled as part of an investigation, an article or reference. Short engineering notes have their own archive.

  • 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 2 of 20 · From source to a running process

    What Is Inside an Executable File: ELF Headers, Segments and Sections

    I opened my three hello worlds with readelf. A program still runs after I delete all its section headers, one changed byte in a segment stops it, and 90% of the Rust file is debug information of the standard library.
  • 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.
  • Published on

    Investigation · Part 1 of 20 · What survives a crash

    Your Data Is Not on Disk When write() Returns

    When write returns, the kernel has your data, but the disk does not have it yet. I measured it on my laptop: 256 MiB sat in RAM until fsync, kill -9 lost nothing, and a power cut could lose everything for up to about 35 seconds.
  • Published on

    Investigation · Part 1 of 20 · From source to a running process

    What Happens When You Run a Program: From execve to main

    My C hello world makes 32 system calls before it prints its line, the static one 14, the Rust one 61. I followed every call back to the code that made it (the kernel, the loader, libc or the Rust runtime) and I timed one start of each.