[systemd-devel] Early review request: socket activation bridge

Lennart Poettering lennart at poettering.net
Thu Oct 10 08:05:43 PDT 2013


On Tue, 08.10.13 02:07, David Strauss (david at davidstrauss.net) wrote:

> I've attached the initial implementation -- not yet ready to merge --
> for an event-oriented socket activation bridge. It performs well under
> load. I haven't tied up all potential leaks yet, but the normal
> execution paths seem to be clean. I also need to use proper shell
> option management.
> 
> The bridge adds about 0.569ms to an average request, which is the same
> overhead I see from a normal, local-network Ethernet hop.
> 
> This is with it wrapping nginx using Fedora's default nginx
> configuration and default homepage:

Hmm, so I have serious reservations about using libev. Quite frankly, I
find its code horrible...

So far we used low-level epoll directly everywhere, though it certainly
isn't particularly fun to use and very limited. In New Orleans Marcel
suggested we should add some kind of event loop abstraction to systemd
that makes working with epoll nicer, and maybe one day even export that
as on API, similar to libevent or libev, but less crazy.

And so I sat down yesterday and wrote some code for this. It's a thin
layer around epoll, that makes it easier to use, makes working with
timer events more scalable (i.e. doesn't require one timerfd per timer
event), and adds event priorisation. I tried hard to make it easy to
use, you find the result here:

http://cgit.freedesktop.org/systemd/systemd/tree/src/systemd/sd-event.h

This should be useful for your specific purpose, but also and especially
to write bus services with. This is going to be part of libsystemd-bus
but useable outside of the immediate bus context, too.

I am planning to port PID 1 and all the auxiliary daemons to it.

> struct proxy_t {

We usually use the _t suffix to indicate typedef'ed types that are used
like a value, rather than an object. (libc does that similar, but not
the same way...). Also, OOM...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list