[LAD] Pipes vs. Message Queues

Clemens Ladisch clemens at ladisch.de
Fri Nov 25 12:33:00 UTC 2011

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.

This benchmark measures data transfer bandwidth.  If increasing that
were your goal, you should use some zero-copy mechanism such as shared
memory or (vm)splice.

> You might be running into some basic scheduler weirdness here though
> and not something inherently wrong with the POSIX queues.

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

> The results with 1M messages had wild variance with SCHED_FIFO,

SCHED_FIFO is designed for latency, not for throughput.  It's no
surprise that it doesn't work well when you have two threads that both
want to grab 100 % of the CPU.

> > 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.


More information about the Linux-audio-dev mailing list