TLDR Dev · ARTICLES & TUTORIALS

HOW MEMORY MAPS (MMAP) DELIVER 25X FASTER FILE ACCESS IN GO

info.varnish-software.com5 min read

Summary from the TLDR Dev newsletter

Memory maps in Unix allow a file to be mapped into virtual memory, enabling direct reads via pointers instead of slower seek/read operations. Benchmarks in Go show memory maps can be up to 25 times faster than using `ReaderAt` for random lookups and iterations. While writing to memory maps is inefficient due to page faults, they can still be great for read-heavy operations when files are cached.