Mehdi Akiki

Posts tagged "linux"

  • Published on

    Investigation · Part 17 of 20 · What survives a crash

    Writing Through mmap: Who Decides When Data Reaches the Disk

    I changed 64 MiB of a file without one write call, through a shared memory mapping. The pages became dirty like in the first part, kill -9 kept them, msync or fsync made them durable, and a truncated file killed my program with SIGBUS. The kernel decides the rest.
  • Published on

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

    What a System Call Costs, and Why Some Calls Skip the Kernel

    On a performance core of my laptop a function call costs 0.6 ns, getpid as a system call 81 ns, and clock_gettime 14 ns through the vDSO but 108 ns as a real system call. I measured both kinds of cores, counted the calls with strace and dumped the vDSO.
  • Published on

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

    Why Freeing Memory Does Not Shrink Your Process

    I freed 999,000 of one million small blocks and the process did not become one kilobyte smaller. malloc_stats, strace and malloc_trim show why: the heap can only shrink from its top, glibc keeps the free pages, and threads multiply the arenas. Rust behaves the same.
  • Published on

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

    When malloc Asks the Kernel for Memory: brk and mmap

    The usual rule says malloc uses brk below 128 KiB and mmap above. I traced seven allocations and a growing Rust Vec with strace: a 129 KiB block came from the heap, a freed 1 MiB block moved the limit, and Vec growth became a chain of mremap calls.
  • Published on

    Investigation · Part 14 of 20 · When the benchmark lies

    Can Environment Variables Change How Fast Your Code Runs?

    A bigger environment moves every variable on the stack, and a 2009 paper showed that small details of the setup can bias benchmarks. I scanned 256 environment sizes three times. The first scan found slow sizes; the shuffled scan showed that they came from the order of the runs.