4 ms·
Memory mapped files also known as sections in VMS/NT have just two advantages: * Fewer context switches among user space / kernel syscalls * No need to co
by rnnr 4y ago
Memory mapped files also known as sections in VMS/NT have just two advantages:
* Fewer context switches among user space / kernel syscalls
* No need to copy _modified_ data into the swap. The behavior for read only data doesn't change
That's it, nothing miraculous about it.
- astrange 4y agoNo, it also shares them between multiple runs of the same process, and it reuses the pages that were in your file cache anyway. > * Fewer context switches among user space / kernel syscalls This is not necessarily true. There's lots of cases where it's actually slower.
- jlokier 4y ago> Fewer context switches among user space / kernel syscalls Note that each page fault to read an mmaped page is also a context switch from user space into the kernel. The kernel entry/exit paths for syscalls and page faults have much in common. Mmaped pages can in principle use fault-ahead to reduce the number of page faults when sequential access is detected. An equivalent reduction is available for read syscalls by reading larger blocks at a time. In practice, mmap files are faster in some scenarios compared with read syscalls and slower in others. Same with O_DIRECT reads, those are faster in some scenarios and slower in others.