clinuxmultithreadingasynchronousaio

Resources associated to an aio_context


The semantics of Linux's Asynchronous file IO (AIO) is well described in the man page of io_setup(2), io_submit(2) and io_getevents(2).

However, without diving in the block IO subsystem, the operational side of the implementation is a little less clear. An aio_context allocates a queue for sending back io_events to a specific client in user-space. But is there more to it ?

More broadly, to which hardware resources (NUMA nodes, CPU cores, physical drives, file-systems and files) aio_contexts should be assigned, and at which level of granularity ?

Maybe it doesn't really matter and aio_contexts are no more than an abstraction for user-space programs. I'm asking since I have observed a performance decrease when concurrently reading multiples files, each with it's own aio_context, compared to a manual Round-robin serialization of chunks requests into a single aio_context.


Solution

  • Note: When dealing with files make sure the filesystem supports the linux async IO hooks and you might need to use O_DIRECT on open() with all it's consequences. A way to simply test this I found is to make lots of requests to a file in one io_submit() call and then check if the all finish simultaneously. If the filesystem falls back to sync IO then everything submitted will finish at the same time.