(no title)
throwaway373438 | 5 years ago
With mmap() of course we only ever have one syscall to create the initial mapping. Everything else is a memory read.
We can get read() down to just one syscall too, with a 4G buffer ;) I can't recall if GB sized buffers are possible, but I have certainly used MB sized read buffers for exactly this reason.
loeg|5 years ago
eloff|5 years ago
throwaway373438|5 years ago
Here's the catch: Large buffer sizes only increase efficiency for sequential reads. mmap() is still much faster for random access within a file. Doubly so, because we need to not just read() but also lseek() for every read.
The inefficiencies of read() can be minimized in the sequential case only.