DIO and AIO

A significant downside of using both the blocking [p]read[v](2) / [p]write[v](2) APIs as well as the mmap(2) (actually much more so with the mmap) is this: they depend on the kernel page cache always being populated with the file's pages (that it's working upon or mapping). If this is not the case—which can happen when the data store is much larger than RAM size (that it, files can be enormous)—it will result in a lot of meta-work by the kernel memory management (mm) code to bring in pages from disk to page cache, allocating frames, stitching up page table entries for them, and so on. Thus, the mmap technique works best when the ratio of RAM to storage is as close to 1:1 as possible. When the storage size is much larger than the ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.