Serialization woes

Masahiro Nakagawa repeatedly at gmail.com
Wed Apr 18 08:47:26 PDT 2012


On Wednesday, 18 April 2012 at 15:02:39 UTC, Andrej Mitrovic 
wrote:
> On 4/18/12, Masahiro Nakagawa <repeatedly at gmail.com> wrote:
>> You can use direct-conversion deserialize
>>
>>      Foo foo2;
>>      msgpack.unpack(data, foo2);
>>
>> instead of
>>
>>      msgpack.unpack(data).as!(typeof(foo));
>>
>> I tested your code on my Mac.
>> Direct-conversion deserialize is 2x or 3x faster.
>
> Wow, I had no idea there was a direct-conversion routine.
>
> On my machine here's the results, first the indirect conversion:
> globals.d(358): saved headers in 2327 msecs
> globals.d(364): loaded headers in 82058 msecs
>
> then the direct conversion:
> globals.d(358): saved headers in 2581 msecs
> globals.d(364): loaded headers in 4260 msecs
>
> That's almost a 20x speed improvement! Fantastic, this solves my
> problems!

I'm glad to hear that :)
But deserialization is still slower than serialization.
I will try to improve the performance.

> But what exactly is the difference between the two
> deserialization routines except the speed itself?

The main reason is the backward compatibility.
First implementation of msgpack-d didn't have the 
direct-conversion deserializer.

Yes, msgpack.unpack isn't a streaming deserialization,
so msgpack.unpack for streaming deserializer is not needed.

I plan to clean up the API, but I need some more time.


More information about the Digitalmars-d mailing list