[LAD] Pipes vs. Message Queues

David Robillard d at drobilla.net
Fri Nov 25 20:51:41 UTC 2011


On Fri, 2011-11-25 at 13:33 +0100, Clemens Ladisch wrote:
> Nick Copeland wrote:
> > > I got curious, so I bashed out a quick program to benchmark pipes vs
> > > POSIX message queues. It just pumps a bunch of messages through the
> > > pipe/queue in a tight loop.
[...]
> The difference between pipes and message queues is that the latter are
> typically used for synchronization, so it's possible that the kernel
> tries to optimize for this by doing some scheduling for the receiving
> process.
[...]
> > > The first result really has me thinking how much Jack would benefit from
> > > using message queues instead of pipes and sockets.
> 
> My guess: not at all, because Jack's payload isn't big enough to matter.

As you say, they are typically used for synchronization, which is
precisely what Jack needs.  It seems reasonable that something
specifically designed for realtime synchronous communication might be
better.  The payload is nothing.

Of course, for just sync, semaphores would probably be best anyway (they
certainly are in a single process but I have never tested shared ones),
but Jack does not use them because it needs to wait on several things,
which you can't do with semaphores.  Message queues are intriguing
because it seems like they could replace both the synchronization pipe
and the server socket, so clients would be using just one wait mechanism
+ communication channel, and a faster one at that.

-dr




More information about the Linux-audio-dev mailing list