Git Product home page Git Product logo

Comments (7)

yfakariya avatar yfakariya commented on July 18, 2024

It helps dynamic object serialization, but your case looks like unintended one. Auto generated serializer should not use PackObject in usual cases, so it seems to be a bug.
Would you show me what type(s) actually packed?

from msgpack-cli.

chrish42 avatar chrish42 commented on July 18, 2024

The exact object being serialized is a Dictionary<string, List<object>>. The object being deserialized is an instance of:

class MsgToDeserialize {
    double[] Results;
    string error;
}

I am working on putting together some code that exhibits the problem for you.

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

The reason of Packer.PackObject is that you use Object type instead of MsgToDeserialized type for item type of the list. The serializer generator uses on-the-fly evaluation to handle actual type of Object items in a list.

I wonder why do you use List<object> instead of MsgToDeserialize , but I will wait for your additional code.

Thank you!

from msgpack-cli.

chrish42 avatar chrish42 commented on July 18, 2024

The messages in each direction are not the same. This is a request/reply RPC system.

The request is a Dict mapping from strings to a list of either int, float, double or string. (So the variable type kinda has to be List<object>, since one key in the dictionary can point to a list of strings and another to a list of ints.)

The reply is either an error message, or a list of double. Does it make a bit more sense now?

from msgpack-cli.

chrish42 avatar chrish42 commented on July 18, 2024

Here is a .cs file with a short program that exercises all the code paths I am using in the MessagePack C# library: https://gist.github.com/chrish42/e975c355f4118ebe2e70

Thanks for looking into this!

from msgpack-cli.

yfakariya avatar yfakariya commented on July 18, 2024

Thank you.

If you use only primitive type or its collection only, you can use List<MessagePackObject> instead of List<Object>. It improves performance about 1000 times faster in my local test because the serializer does not have to attempt complex object tree serialization.

You can find API document here:
http://cli.msgpack.org/doc/html/T_MsgPack_MessagePackObject.htm

If you need more sample code snippets for MessagePackObject handling, it is better to post to issue 13 rather than this post :-)

I will improve the wiki to notice this performance pit anyway. Thanks!

from msgpack-cli.

chrish42 avatar chrish42 commented on July 18, 2024

The change to MessagePackObject fixes the performance problems, thanks. Happy to hear you will also be improving the documentation with respect to this. Also, for people who do need complex object tree serialization for List<object>, etc. a LRU cache of the results for compile() in the packToCore() function might help a lot in cases when the same small number of complex objects a serialized a lot. Just a suggestion...

Closing this issue, as the switch to MessagePackObject fixes my performance problems with MessagePack. Thanks again for your time. Much appreciated.

from msgpack-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.