[zeromq-dev] ØMQ VSM data alignment

Jon Dyte jon at totient.co.uk
Wed Aug 4 21:07:59 CEST 2010


Matt Weinstein wrote:
> First thing zmq does is close the old message:
>
> e.g.
> rep.cpp : 190
>
>    // Deallocate old content of the message.
>      zmq_msg_close (msg_);
>
> On Aug 4, 2010, at 2:19 PM, Jon Dyte wrote:
>
>   
I see.
It's coming back to me now, I'm getting confused with some old code 
which combined 0MQ/REQ-REP and tokyo cabinet.

And yes I seem to recall on the client side after the recv doing memcpy 
on to appropriate structures.

Jon

>> Matt Weinstein wrote:
>>     
>>> On Aug 4, 2010, at 1:37 PM, Andrew Hume wrote:
>>>
>>>       
>>>> this sort of thing can get problematic quickly.
>>>> the combinatorial explosion of cache-line design, memory design,
>>>> language alignment rules, architectures allowing non-aligned  
>>>> references
>>>> (but punishing you with slowness) makes testing hard.
>>>>
>>>> on the other hand, starting on a 8 byte boundary is always a good
>>>> idea in modern architectures.
>>>>
>>>> better style is to use a byte stream so you won't get bitten by
>>>> LSB/MSB issues
>>>> or packets coming from other machine architectures.
>>>>
>>>>         
>>> Yes, but I want to do this:
>>>
>>>    zmq::message_t foo;
>>>
>>>    s.recv(&foo);
>>>    my_struct const* pstruct = reinterpret_cast<my_struct
>>> const*>(foo.data());
>>>
>>>    cout << "Works like magic: " << pstruct->member << ". All your
>>> processor are belong to Intel! (*)" << endl;
>>>
>>> That's the no-copy approach :-)
>>>
>>> I can do it with malloc() without issue or penalty...
>>>
>>> (*) There are no other architectures :-)
>>>
>>>       
>> I havent ever tried, but does this not work?
>>
>>    my_struct ms;
>>    zmq::message_t foo(&ms, sizeof(my_struct), NULL, NULL);
>>    s.recv(&foo);
>>
>>    // now i think here you would have to to check the size was sizeof
>> my_struct. and the data() is indeed the address of ms.
>>
>>
>>
>> Jon
>>
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>     
>
> _______________________________________________
> 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