Mehdi Akiki

Posts tagged "c"

  • 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 · 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.
  • Published on

    Investigation · Part 8 of 10 · Following a TCP connection

    How a Name Becomes an Address: What getaddrinfo Really Does

    Connecting to localhost took 77 microseconds and connecting to 127.0.0.1 took 12, to the same server. I followed getaddrinfo with strace: four sources tried in order, files read on every call, answers sorted with IPv6 first, and a lookup that blocks the thread.