Asynchronous File I/O on Linux

Mark Woodward markw-FJ05HQ0HCKaWd6l5hS35sQ at public.gmane.org
Sat May 15 15:23:24 EDT 2010


Does anyone know of a standard asynchronous file I/O system for Linux?

I just wrote one because I needed to try something, but I was wondering if
there is a more mainstream project going on. From what I've been able to
find, you can't do much better than what I did with the POSIX API and that
was open a file multiple times, use posix threads, mutexes, and events to
queue up I/O requests to the threads.

Specifically, does anyone know of a call that will take an existing file
handle and FULLY duplicate it so that each will have their own notion of
file position? (dup() and dup2() do not do this.) This could improve my
performance.

My test case is as such:

int fin = open(...)
read(block, size);
seek(offset, whence)
read(block2, size);
seek(offset, whence)
read(block3, size);
seek(offset, whence);
read(block4, size);
close(fin)

Vs

Asyc = asyncOpen(...)
readblock(block,size,offset,whence);
readblock(block2,size,offset,whence);
readblock(block3,size,offset,whence);
readblock(block4,size,offset,whence);
asyncWait();
asyncClose()

When all is said and done, the async is about 3%~4% slower in this case.
While it will probably be a huge gain for an app that can actually use
async, I was kind of hoping that by putting all the requests out at once,
the file system, block drivers, and disk drive would do a better job at
parallelizing the disk reads and getting the blocks faster with fewer disk
platter rotations. But, alas, performance seems no better than sequential
reads and I can attribute the slowness to the added overhead.


Anyone have any ideas?






More information about the Discuss mailing list