[zeromq-dev] Improving latency using futexes?

Martin Sustrik sustrik at 250bpm.com
Tue Nov 24 17:25:46 CET 2009

Hi all,

I've did a little experiment with using futex instead of mutex to 
implement a simple semaphore object (applies to Linux only).

My assumption was that by using futex directly we avoid an atomic 
operation that glibc mutex performs in user space before passing control 
to the kernel.

However, I haven't seen any latency improvement whatsoever. Any ideas of 
why it is so? (My naive guess is that both threads to be synchronised by 
the semaphore were scheduled on the same core, thus the atomic operation 
  was extremely fast as it haven't required any cache coherency 
measures, bus locking etc.)

Those that like to mess with dark kernel magic, see the patch attached.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: futex.patch
Type: text/x-patch
Size: 2229 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20091124/131ca6b7/attachment.bin>

More information about the zeromq-dev mailing list