Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance #67

Open
repeatedly opened this issue Aug 11, 2015 · 2 comments
Open

Improve performance #67

repeatedly opened this issue Aug 11, 2015 · 2 comments

Comments

@repeatedly
Copy link
Member

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.

@yannick
Copy link
Contributor

yannick commented Aug 11, 2015

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

@repeatedly
Copy link
Member Author

Thanks for the info. I will check it later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants