Asynchronous buffered read operations
Asynchronous buffered read operations
Posted Mar 20, 2015 15:05 UTC (Fri) by Cyberax (✭ supporter ✭, #52523)In reply to: Asynchronous buffered read operations by mtanski
Parent article: Asynchronous buffered read operations
And there's no real way to do it asynchronously in one thread - poll/epoll don't work for disk IO and aio doesn't work for sockets.
Posted Mar 20, 2015 15:17 UTC (Fri)
by mtanski (guest, #56423)
[Link] (1 responses)
Posted Mar 20, 2015 15:38 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link]
> 2. Build yourself a threadpool for handling IO.
And really, I don't see disk IO that much different from the network IO.
You have two options:
Asynchronous buffered read operations
1. io_submit(), eventfd(), poll() the eventfd
Any requests you submit via io_submit can have an optional notification via eventfd. You have to set that in the struct iocb. The downside is that you're limited to O_DIRECT and it can still block in some cases.
2. Build yourself a threadpool for handling IO.
This is kind of what everybody does today who doesn't do O_DIRECT. It still issues like introducing latency (synchronization, slow requests). This is what this RWF_NONBLOCK addresses it lets you try doing a "fast read" from your network thread, so you can skip the threadpool if the data is there (because of kernel readahead or because it's hot data).
Asynchronous buffered read operations
You really have to do it from a separate thread.
That's what everyone does since there's really no way around it. That's why it would be nice to have a unified asynchronous API.