mmap maps a file (or anonymous memory) into a process's address space, so reads and writes become ordinary memory accesses; the OS loads pages on demand through the page cache and writes dirty pages back.
Benefits: no explicit read and write calls, less copying, shared memory between processes mapping the same file, and fast access to large files such as datasets or model weights.
Loading…