Content-Length: 11148 | pFad | http://lwn.net/Articles/637403/

Asynchronous buffered read operations [LWN.net]
|
|
Subscribe / Log in / New account

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

The problem here is in multiplexing. It's extremely common to have a loop that reads data from a disk and puts it into a network socket.

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.


to post comments

Asynchronous buffered read operations

Posted Mar 20, 2015 15:17 UTC (Fri) by mtanski (guest, #56423) [Link] (1 responses)

You have two options:

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

Posted Mar 20, 2015 15:38 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

> 1. io_submit(), eventfd(), poll() the eventfd
You really have to do it from a separate thread.

> 2. Build yourself a threadpool for handling IO.
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.

And really, I don't see disk IO that much different from the network IO.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://lwn.net/Articles/637403/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy