[dovecot] PATCH Add support for kqueue in ioloop subsystem
Hey,
I noticed that there was an ioloop "module" (if we can call it that) for select and poll and decided to add one for kqueue (aka kevent) BSDs high performance descriptor multiplexing API. I haven't done any of the configure glue stuff but the code is complete and works well. kqueue is available on all recent versions of FreeBSD, NetBSD, OpenBSD and Darwin (and therefore MacOS X). I've tested both pop3 and imap with no problems.
To get it working: (bodge method)
- replace IOLOOP_POLL (or IOLOOP_SELECT) with IOLOOP_KEVENT
- find liblib_a_SOURCES add ioloop-kevent.c to it
- find liblib_a_OBJECTS add ioloop-kevent.$(OBJEXT) to it
make
vi src/lib/Makefile
tar zxvf dovecot-0.99.8.1.tar.gz cp ioloop-kevent.c dovecot-0.99.8.1/src/lib/ cd dovecot-0.99.8.1/ ./configure vi config.h
There is a paper on kqueue which includes a performance evaulation here:
http://people.freebsd.org/~jlemon/papers/kqueue.pdf
Thanks,
Dominic
<dom at cus.org.uk>
On Wed, 2003-04-16 at 22:33, Dominic Marks wrote:
I noticed that there was an ioloop "module" (if we can call it that) for select and poll and decided to add one for kqueue (aka kevent) BSDs high performance descriptor multiplexing API. I haven't done any of the configure glue stuff but the code is complete and works well. kqueue is available on all recent versions of FreeBSD, NetBSD, OpenBSD and Darwin (and therefore MacOS X). I've tested both pop3 and imap with no problems.
Thanks. I'll add the configure stuff there. Some comments:
-- if (kevent(data->kq, &data->event, 1, NULL, 0, NULL) < 0) { i_warning("couldn't add filter with kqueue: %m"); }
Maybe that should be i_fatal() instead? Otherwise the socket would get ignored and never closed.
-- if (kevent(data->kq, &data->event, 1, NULL, 0, NULL) < 0) { /* * changing this to i_fatal is debatable, however * if you do so you will potentially expose the case * where a process receives the client from a socket * then closes the listening socket, experiences an * error and calls exit, dropping the client we just * picked up */ i_warning("couldn't remove filter with kqueue: %m"); }
Can this error actually happen when removing it? What kind of error?
-- * in. However here we have to process them in io handler * priority order, which means we then need to go through * our events and see if we have a match.
Maybe I should remove the priorities. They're just slowing down things and there's no real reason for them now.
Also I have in TODO:
- send EXISTS immediately after new mail arrives.
- linux: we can use dnotify for maildir (but not mbox I think, we'd
get interrupted all the time if we checked eg. large /var/spool/mail)
- *bsd: kqueue() can notify changes in mbox and maildir
This would need some kind of API as well..
participants (2)
-
Dominic Marks
-
Timo Sirainen