[zeromq-dev] [PATCH] Add ZMQ_RCVTIMEO/SNDTIMEO sockopt (fix)

Fabien Niñoles fabien.ninoles at gmail.com
Sun Jun 12 18:09:54 CEST 2011

Hi Martin,

I understand the concern, I just wonder if this was a bottleneck issue
at all:  polling is the very last thing we try when there is no other
message pending in the mailbox.  So, basically, I think we only gain
any performance when the throughput is low enough to let part of the
system waiting for something to do.  I'm also not sure if replacing
the polling with the 4 ioctl calls really speed up things.  Better
optimization could /may be/ to use the RCV_TIMEO on the mailbox reader
socket on the platform that support it (unless the behavior is
unacceptable, like it seems to be the case on Windows, according to
the doc).  With MSG_DONTWAIT support, that's really reduce the number
of syscalls a lot (a single recv in all case).

So here the patch for the old blocking case behavior.  I would see if
I can implement the RCV_TIMEO options now.  Someone else would have to
check it on Windows however.


2011/6/12 Martin Sustrik <sustrik at 250bpm.com>:
> Hi Fabien,
>> That's make the code quite more complex to keep the exact same code
>> path.  We need to go back to the old three cases (Windows,
>> MSG_DONTWAIT and pure BSD) when timeout is -1, as well as to handle
>> the MSG_DONTWAIT special case when timeout != -1.  I will do that, but
>> I'm not sure it worth the added complexity.  May be we could instead
>> work on an optimized internal version of zmq_poll for our special case
>> (single socket, always the same with the same option) ?
> poll+recv is always going to be slower than recv alone.
> As for the value of the whole thing, the high performance achieved by 0MQ
> was *very* costly to implement. Too costly, IMO, to be thrown away because
> of minor implementation problem.
> I would suggest starting with the original codebase and simply inserting the
> pieces of the patch enclosed in "if (options.rcvtimeo >= 0) {...}"
> Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-sockopt-ZMQ_RCVTIMEO-ZMQ_SNDTIMEO.patch
Type: text/x-patch
Size: 30548 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110612/4ccef35d/attachment.bin>

More information about the zeromq-dev mailing list