Proof-of-concept implementation and benchmark of zero-copy shared-memory transport
Switch branches/tags
Nothing to show
Latest commit dc763fe Dec 29, 2012 Aliaksey Kandratsenka Correctly documented beautiful API I've built 4 years ago
Because my memory doesn't serve me well I had to read this code like
new. Hopefully next time it won't happen.


All this code is under public domain.

This is my old experiment with shared-memory transport. It uses some
linux-specific facilities (futex & eventfd) and compares throughput of
shared memory 'pipe' (zero-copy) versus plain pipe (obviosly, copying).

You'll need libatomic-ops-dev and recent-enough Linux. But pipe
eventfd emulation should be compile-able on any Unix. And you may need
to tweak Makefile a bit.

Quite surpisingly, even minimal data processing pretty much negates
speed benefits of zero-copy shared memory transport (remove
JUST_MEMCPY define to see youself).

Another interesing thing is that old wakeup-via-pipe trick (used by
main_emulation) is not so much slower than efficent eventfd (0.44
seconds vs. 0.33 seconds).

My results: piping 300000000 (300 megs) of data takes:

./main_pipe (plain read & write to/from pipe)
~0.68 sec

./main_emulation (portable eventfd emulation via pipe)
~0.44 sec

./main_futex (futex variant)
~0.93 sec

./main_eventfd (eventfd variant 1)

./main_efd_nonblock (eventfd variant 2)

A bit more elaborate processing of data (generation & verification via
nrand48) gives times around 10 sec, where difference between pipe
implementation doesn't matter that much.