[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Different behavior of my code



On Fri, Sep 9, 2011 at 12:32 AM, Scott Lamb <slamb@xxxxxxxxx> wrote:
> I see your point, fwiw. I just wish it were possible to do much better
> than that, but I don't think it is given the available OS interfaces.
> One could imagine a bufferevent implementation that used aio, though
> I'm not sure what OSs have a satisfactory aio implementation...

It looks like Linux's might be okay. At least the io_* functions
defined in <libaio.h> appear to work fine. This is a completely
Linux-specific interface, but despite what some webpages say, it
doesn't seem to require anything special on a modern system (in
particular, O_DIRECT is not required and so neither are aligned
operations). You can also poll for these events with epoll through
io_set_eventfd. The manpages have some ambiguity about if the standard
aio interface is built on top of this or still the thread-based
implementation in glibc, and I haven't tried it to find out.

According to the respective kqueue manpages, it seems like FreeBSD may
also have a suitable aio implementation, but not OS X.

So it'd be possible to build a pleasantly abstract libevent api for
asynchronous pread(), pwrite(), fsync(), fdatasync() operations which
is implementable on Linux and FreeBSD (kqueue only), and on top of
that build a (more limited) bufferevent implementation as well if you
like. Anything else is missing, though - open(), close(), fstat(),
ftruncate(), sync_file_range(), etc. just have the blocking versions,
which is a shame.

-- 
Scott Lamb <http://www.slamb.org/>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.