mmap vs. Traditional I/O: Why Llama.cpp Loads 100x Faster

Llama.cpp switched to `mmap()` from standard C++ I/O (like `fread`) to avoid copying massive model files into RAM, directly mapping them from disk to virtual memory. This 'zero-copy' approach eliminates redundant data transfers between kernel and user space, significantly reducing load times and memory footprint compared to traditional methods that involve two data copies.

Sources

Open the full topic