littledan / linux-aio

How to use the Linux AIO feature
324 stars 42 forks source link

Lack of new threads. #4

Open twopieman opened 4 years ago

twopieman commented 4 years ago

Please correct me if I am wrong since I am basically transitioning over from windows to linux and am slowly building my mental model around Linux.

This application seems to in a loop submit an IO request and then try and reap the completion on that same thread, this seems counter-intuitive to how i think async IO is meant to be used. Ideally you would have a thread\ bunch of threads perform I/O's or submit I/O's (in Linux AIO jargon) and then have a separate pool of threads reaping the I/O completions. The way this sample application is written it simply performs the I/O in a very synchronous manner even though it is using Linux AIO under the covers.

I am interested in your thoughts around this.

littledan commented 4 years ago

I believe Linux AIO is threadsafe: you can submit requests from several threads on the same io_context_t. However, you can also use just one thread, and the I/O will be done in parallel. Both are valid patterns.