[zeromq-dev] ØMQ VSM data alignment
Matt Weinstein
matt_weinstein at yahoo.com
Sat Aug 7 13:40:15 CEST 2010
That's what gcc on CENTOS5/64 reported ...
I like Martin's solution to put vsm_data at the head of the structure.
In that case you get an added "feature": if you overrun the vsm_data
you'll trash your own structure, so you'll know whose fault it is. :-)
On Aug 6, 2010, at 11:13 PM, Ben Kloosterman wrote:
>>> 0x00 void *content;
>>> 0x08 unsigned char flags;
>>> 0x09 unsigned char vsm_size;
>>> 0x0a unsigned char vsm_data [ZMQ_MAX_VSM_SIZE];
> This is incorrect in most cases its
>
> 0x00 void *content;
> 0x08 unsigned char flags;
> 0x0a unsigned char vsm_size;
> 0x0d unsigned char vsm_data [ZMQ_MAX_VSM_SIZE];
>
> Unless you force packing which is not great for performance ( pack
> 1 was
> probably -3% performance )
>
> I posted a code fragment to the list last week which
> - used a union
> - combined flags and size into 1 int field since it uses 4 bytes
> anyway (
> you can also use 24 bits for size and remove 4 bytes size from large
> messages - max msg size is then 16Meg)
> - set ZMQ_MAX_VSM_SIZE to ensure the total sizeof was 32 bytes
> ( which was
> 28)
> - Put the data at the start so it would be 16 byte aligned
> - Set the struct for 16 byte alignment
>
> benchmarked it using VS and got a 2-3% improvement , With Intel I
> suspect
> you will get more as it may use the 8 / 16 byte SSE2 copying which
> needs 16
> byte alignment. If your compiler defaults to pack 1 change it ,
> alignment is
> more important.
>
> Ben
>
>> -----Original Message-----
>> From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-
>> bounces at lists.zeromq.org] On Behalf Of Pieter Hintjens
>> Sent: Thursday, August 05, 2010 1:09 AM
>> To: 0MQ development list
>> Subject: Re: [zeromq-dev] ØMQ VSM data alignment
>>
>> Matt,
>>
>> I don't think this has been covered. It would be sensible to have
>> vsm_data aligned but it's something that is IMO worth testing rather
>> than doing on faith.
>>
>> -Pieter
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list