Mehdi Akiki

Posts tagged "memory management"

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

    What fork Really Copies: Copy-on-Write Measured

    fork of a process with 2 GiB of touched memory took 16 ms here, because it copies page tables and not memory. I measured the copies that come later when the child writes, what reading costs, what happens to huge pages, and why posix_spawn stays under a millisecond.
  • Published on

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

    Why the First Touch of Memory Is Slow: Demand Paging Measured

    Mapping 1 GiB takes no time, the first write to each page costs about a microsecond, and the second write 16 nanoseconds. I measured faults with and without huge pages, MAP_POPULATE, calloc and Rust vectors, and twice the compiler removed the work I wanted to measure.
  • Published on
    Rust's concept of sizedness is crucial to understanding how the language manages memory, especially when dealing with types like slices, trait objects, and user-defined unsized types. This article explores the intricacies of the Sized and !Sized traits, and their impact on Rust programming.