[boost] [asio] file i/o under linux

298 views
Skip to first unread message

Kamil Nowosad

unread,
Mar 15, 2011, 2:43:00 PM3/15/11
to bo...@lists.boost.org
Hi,

I have been working recently on support for asynchronous file i/o in
asio library in linux. Perhaps some of my code will interest you.

The interface allows for doing read, write and fsync/fdatasync
operations. The implementation uses either POSIX AIO or linux-native
libaio (this may be currently switched by #define ASIO_USE_LIBAIO).

I have based the initial work on patch brought by Felipe Magno de
Almeida in 2005 (http://lists.boost.org/Archives/boost/2005/09
/93068.php). As you may realize by studying my modifications of
task_io_service, the file i/o operations are unable to coexist with
operations of other kind within single io_service. I did not have time
to test it thoroughly, but basic tests pass.

The patch is created against 1_45_0 version, however everything works
well when applied to 1_46_1. The tarball contains also a simple example
file and a script that compiles it.

I will be pleased to receive any feedback.

--
Best regards,
Kamil Nowosad

asio.aio.tar.gz

Gruenke, Matt

unread,
Mar 16, 2011, 12:13:08 PM3/16/11
to bo...@lists.boost.org
I'm definitely planning to take a look.

I started experimenting with Posix Async I/O and found aio_suspend() use a design that scales poorly and have high overhead, under Linux. Furthermore, it doesn't seem to interoperate natively with other forms of I/O multiplexing (perhaps as reflected in your dedicated io_service limitation). On Linux, it has several significant limitations: it doesn't work on certain filesystem types, writing can still sometimes block, and it forces O_DIRECT - which disables caching and imposes alignment limitations. Even without the implementation issues, I would not recommend using this interface.

I did not experiment with the signals approach, but I'm also concerned about the overhead and scalability of that model. Furthermore, it didn't seem to fit ASIO's architecture as cleanly.

I also did not experiment with native Linux API, though I believe it shares the limitations of the Posix AIO implementation. One benefit of the native Linux interface is that I believe you can get a file descriptor that you can use with epoll() to drive it with a normal io_service.


Matt


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply all
Reply to author
Forward
0 new messages