msgpack-d icon indicating copy to clipboard operation
msgpack-d copied to clipboard

Improve performance

Open repeatedly opened this issue 8 years ago • 2 comments

msgpack-d has a room for performance improvement.

http://forum.dlang.org/thread/[email protected]

From above thread, cerealed has similar performance with msgpack-d. I use modified benchmark script which adds more types.

import std.stdio;
import std.conv;
import std.datetime;
import std.algorithm;
import std.array;
import cerealed;
import msgpack;


struct Struct {
    bool b;
    int i;
    double d;
    string s;
    string[string] aa;
    int[] a;
}

Struct testStruct;

void withCerealed() {
    auto enc = Cerealiser();
    enc ~= testStruct;
    enc.cerealise!((bytes){});
    auto s = Decerealiser(enc.bytes).value!Struct;
    assert(s == testStruct);
}

void withMsgPack() {
    auto bytes = pack(testStruct);
    auto s = bytes.unpack!Struct;
    assert(s == testStruct);
}

void main() {
    testStruct = Struct(true, 5, 3.14, "hi there, nice to meet you!", ["leindex": "levalue"], new int[](20));
    auto results = benchmark!(withCerealed, withMsgPack)(1_000_000);
    writeln("Cerealed: ", to!Duration(results[0]));
    writeln("MsgPack:  ", to!Duration(results[1]));
}

On my MacBook result:

dmd 2.0.68.0 with -inline -release -boundscheck=off:

Cerealed: 3 secs, 12 ms, 667 μs, and 5 hnsecs
MsgPack:  2 secs, 39 ms, 340 μs, and 2 hnsecs

ldc2-0.15.2-beta2 with -O3 -inline -release:
Cerealed: 2 secs, 205 ms, and 873 μs
MsgPack:  1 sec, 377 ms, 916 μs, and 6 hnsecs

I will check memory usage later.

repeatedly avatar Aug 11 '15 06:08 repeatedly

yesterday i did some profiling for a use case i have. its more or less logfiles from a webserver which i store as msgpack frames. the application code is not very optimized but it might be still interesting for you to see some numbers. run on OS X 10.10.

profile from extracting 25000 records from a gzip'd stream https://gist.github.com/b0a69efb791b40441984 profile=GC extracting 1950000 records from a gziped stream https://gist.github.com/c718184e0c6035c996c1

if usefull i can provide more numbers/info

yannick avatar Aug 11 '15 13:08 yannick

Thanks for the info. I will check it later!

repeatedly avatar Sep 23 '15 21:09 repeatedly