linux - what is difference between io_submit and file with O_ASYNC -


i reading tutorial asynchronous disk file io, doesn't make me clear, , makes me more confused.

there 2 different async io models according tutorial:

  1. asynchronous blocking i/o: open file o_async, , using epoll/poll/select.
  2. asynchronous io: using glibc aio in article. since glibc implementation simulation via thread pool, refer in question kernel aio, i.e. io_submit.

at least concept point-of-view, there no big difference, true, io_submit can let issue multiple io reqeusts, , on other hand, using read o_async, can issue 1 request implicated file position.

and guide mentioned using epoll alternative linux aio:

epoll. linux has limited support using epoll mechanism asynchronous i/o. reads file opened in buffered mode (that is, without o_direct), if file opened o_nonblock, read return eagain until relevant part in memory. writes buffered file immediate, written out writeback thread. however, these mechanisms don’t give level of control on i/o direct i/o gives.

what issue of using epoll aio alternative? or in other words, problem need new interface io_submit solve?

to opinion, critical issue behind io_* api ability achieve higher io throughput through 2 main measures:

  1. minimization of number of system calls in application io loop. multiple request batches can submitted, then, @ later time, application can return examine outcomes of individual requests in 1 go using io_getevents(). importantly, io_getevents() return information on each individual io transaction, rather vague "fd x has pending changes" bit of info returned epoll() on each invocation.

  2. kernel io scheduler can rely on request reordering make better use of hardware. application may pass down tips on how reorder requests using aio_reqprio field in struct iocb. necessarily, if allow reordering of io requests, need supply application appropriate api query, whether particular high priority requests completed (thus io_getevents()).

it can said, io_getevents() important piece of functionality, whereupon io_submit() handy companion make efficient use of it.


Comments