[zeromq-dev] zmq_msg_* functions don't check for message validity
Martin Sustrik
sustrik at 250bpm.com
Fri Apr 15 07:11:32 CEST 2011
On 04/14/2011 05:22 PM, Pieter Hintjens wrote:
> On Mon, Apr 11, 2011 at 11:48 AM, Martin Sustrik<sustrik at 250bpm.com> wrote:
>
>> The problem with zmq_msg_t is that it's on the critical path. The
>> structure itself is very compact and has no space for a runtime tag.
>> Also the code dealing with it is highly optimised and presumably should
>> not do any additonal memory access operations.
>
> Two bytes for a tag does not seem significant.
> Also, is checking for sockets (which no-one actually asked for) not on
> the same critical path?
The socket tag is going to be in L1 cache permanently, so there's almost
no associated cost. Messages are loaded from memory all the time, so any
change to zmq_msg_t structure should be carefully considered. It's also
this structure that's accountable for almost all the memory usage in
very small message scenarios so the size of the structure is important
(Actually, I have an idea how to get the size down from 48 bytes to 32
bytes, which would mean up to 33% memory usage less in such scenarios.)
>
>> However, if there's strong need for this kind of functionality, we can
>> allow it to be switched on at the compile time, say when --enable-debug
>> is used.
>
> I'd say the need for checking on messages is stronger than on sockets
> and contexts, since the API for messages is more complex and easier to
> get wrong.
>
> Switching it on and off is fine but the default should be 'on' IMO.
Agreed, checking for validity is important. Now when we speak of it, I
realise there are 6 bits unused in the structure. We can use those to
tag the message.
Martin
More information about the zeromq-dev
mailing list