Skip to content
/ shm_pipe Public

Proof-of-concept implementation and benchmark of zero-copy shared-memory transport

Notifications You must be signed in to change notification settings

alk/shm_pipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
~0.40

./main_efd_nonblock (eventfd variant 2)
~0.33

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.

About

Proof-of-concept implementation and benchmark of zero-copy shared-memory transport

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages