I am writing a C program to read data from an SSD drive by reading directly from the raw block device file.
I am trying the Linux AIO (I am talking about the Linux AIO API, i.e. the functions provided by linuxaio.h
, such as io_submit(...)
etc., not the POSIX AIO API). I open the block device file using the O_DIRECT
flag and I make sure that I write to buffers are aligned to block size.
I noticed that Linux AIO it is considerably faster than using syncronous IO also with O_DIRECT
flag.
The thing that surprised me the most is that the throughput achieved by issuing many small random reads of few KBs each with Linux AIO is remarkably higher even than the throughput achieved doing a large (sequential) read of few MBs using synchronous I/O and O_DIRECT
.
So, I would like to know: how come Linux AIO peforms that better than syncronous I/O? What does the kernel do when AIO is used? Does the kernel perform request reordering? Does using Linux AIO result in greater CPU utilization than using synchronous I/O?
Thanks a lot in advance