[zeromq-dev] zmq::poll timeout returns immediately on MacOS/X 10.5

Martin Sustrik sustrik at 250bpm.com
Fri Jun 11 07:16:35 CEST 2010


Matt Weinstein wrote:

> What would the kernel do? :)

Kernel would trade performance for POSIX-compliance.

At least I hope so :)

> One tack might be one condition variable per user thread, and a high- 
> priority service thread running a wake-up queue (pointing at a list of  
> unrolled lists...)?

Let me explain the problem: To do exact timouts, zmq_poll would have to 
measure exact time (gettimeofday) at the beginning of the function. If 
it doesn't know the time it was invoked, it cannot terminate at right time.

This time measurement is the impact I am speaking of. Although it may 
seem negligible, in a tight loop it can decrease overall throughput (I'm 
guessing here) by ~30%.

One way to solve the problem would be to use some fast mechanism (such 
as rdtsc on x86/64) to find out whether noticeable time has elapsed 
since last call to zmq_poll (say at least 1ms), call gettimeofday only 
if it did, and use the previous time measurement if it didn't.

Of course, this would leave non-x86 platforms with the full performance 
impact.

Anyone volunteers to give it a try?
Martin



More information about the zeromq-dev mailing list