John Fremlin's blog: ULib - C++ IO framework

Posted 2009-08-18 23:40:00 GMT

Stefano Casazza's excellent, and now newly released, ULib framework pulled ahead of teepeedee2 (11757.27 requests per second vs 11313.29 for tpd2). This framework shares many of the goals of teepeedee2: a stripped down set of language features used, and is a general system for doing all sorts of IO (for example, it includes a nicely Object Orientated HTTP client).

I'm curious about the search engine component of ULib, but I've been too busy to check it out. Maybe I will be able to have a look at it another time. Please feel free to comment if you've used it.

It diverges from tpd2 with the fact that (like the original teepeedee) it is written in C++, so doesn't have to contend with Lisp related idiocies regarding pointers (teepeedee2 has to pass both the start and end offsets as well as a pointer to array itself instead of just a pointer and a length, as displaced arrays are a performance joke under SBCL). Additionally, ULib can run on MS Windows and has some documentation, which puts teepeedee2 to shame.

Stefano introduced me to an interesting pair of socket options — TCP_DEFER_ACCEPT (in teepeedee2 now), which is a stripped down version of FreeBSD's kevent accept filters that means the accept(2) system call will only return if at least one data packet has arrived, and TCP_CORK. I was using TCP_CORK before, though with the writev mechanism it is not so generally useful, but I found it to cause the time waiting for the buffer to be flushed to be charged to the teepeedee2 process. Stefano never uncorks the socket (this is fine for Connection: close mode as the close(2) will flush everything), so never incurs the penalty. He measured a nearly 10% benchmark increase from using it. I tried it but without determining that there was any measurably significant benefit.

(On a related note, what is happening with the new accept4(2) syscall which should save setting O_NONBLOCK with fcntl? The wrapper for it seems not to have made it to libc yet.)

It's fine to see a competitive framework to compare teepeedee2 to, and I hope Stefano and I will continue to share ideas. ULib is officially the fastest — let's see if I can squeeze out another 4%.

Post a comment