I'm using the Linux kernel AIO through libaio, and I have to submit the next reading operation before the previous one was completed. The problem is that io_submit()
blocks for some time and, as I can deduce from the interval, it waits the previous operation to be completed.
I know that I can enqueue a several operations with a single io_submit()
, but it is not an option for me, because I don't know how exactly the next read operation would like when it's already a time to submit the first one.
Is it working like that only for me, or for everyone? In the second case, may I ask if I'm looking for something feasible, or I have to fallback to a threaded model?
io_submit
will block under weird, unpredictable conditions (which is why I'm not using it). I once asked around and got an answer like "of course, it has to work that way, there is a limited-size request queue". Happens that e.g. doing one large request may be broken into several smaller ones, so... queue full and blocks. The threaded glibc async I/O implementation works better but be aware that it will spawn threads on demand (if that is not acceptable, use your own pool of workers). – TorrezO_DIRECT
, which is a major anti-optimization, and aligned reads), you may still haveio_submit
block. If, for whatever reason, filesystem metadata needs be read, this will block insideio_submit
, and you're out of luck. Sadly, blocking and waiting for one seek is about the same as waiting for several megabytes transferred anyway, so this renders aio kinda pointless. – Torrez