[zeromq-dev] Jzmq Performance Issues

Chuck Remes cremes.devlist at mac.com
Wed Feb 23 01:42:28 CET 2011

On Feb 22, 2011, at 5:45 PM, Yusuf Simonson wrote:

>> So do you see why the addition of a "sleep" call doesn't make sense? That is, how does a call to sleep make a message magically arrive?
> I haven't tested enough to be 100% sure, but I think what sleep is doing is giving the application enough time to queue up a message for the socket before it calls recv(). Thus recv() only permanently blocks if the message queue is empty.

Not possible. All queue manipulation done by the 0mq library happens in a separate I/O thread. You can have dozens/hundreds/thousands of sockets blocked on recv() and 0mq will happily start delivering data to their "mailboxes" as it arrives.

If you are experimenting with the socket pairs, it could be a message race condition. That is, you sent the message before the receiver had connected to the socket. The sleep gives your receiver time to finish its bind/connect to the transport address.

This is a pretty common mistake. I recommend looking at the examples in the 0mq guide; many of them have notations describing how to solve this.


More information about the zeromq-dev mailing list