I/O technologies – a quick comparison

The following table provides a quick comparison to some of the more salient comparison points between the four to five Linux I/O technologies we have seen, namely: the blocking read(2)/write(2) (and the SG-I/O/positioned [p]read[v](2)/[p]write[v](2)), memory mapping, non-blocking (mostly synchronous) DIO, and non-blocking asynchronous AIO:

I/O Type APIs Pros Cons

Blocking (regular and SG-IO / positioned)

[p]read[v](2) /[p]write[v](2) Easy to use Slow; double-copy of data buffers
Memory Mapping mmap(2) (Relatively) easy to use; fast (in memory I/O); single copy of data (a zero-copy technique); works best when RAM:Storage :: ~ 1:1 MMU-intensive (high page table overhead, meta-work) when RAM: Storage ...

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.