Giter Club home page Giter Club logo

Comments (4)

stephenberry avatar stephenberry commented on August 27, 2024

Serializing to a pre-allocated buffer versus a dynamic buffer like std::string typically has less than a 5% difference in performance. Furthermore, in inter-process communication you should typically reuse your serialization buffer. Glaze uses a doubling of the buffer capacity if growth is needed, so it is rare that you will have new allocations if you reuse your serialization buffer.

Is there a reason why you can't reuse a std::string (serialization) buffer?

A function to calculate the serialization size could be added, but it would need to iterate through your structures. This would actually add more overhead than simply reusing the std::string buffer. So you might have a tiny performance boost for the very first message you send, but subsequent messages would run slower needing to compute the size beforehand.

from glaze.

alan0526 avatar alan0526 commented on August 27, 2024

Before if I use string I need to serialize to std::string then write it to shared memory, there is an extra copy.
And the reason why I need to size is I want to know what the size of the shared memory to be created.

from glaze.

stephenberry avatar stephenberry commented on August 27, 2024

I see. I'll keep this issue alive to add the ability to compute the space required before serialization.

I typically use shared libraries which allow me to share the std::string directly across processes, which allows dynamic buffer sharing and avoids the extra copy. But, I can see how if you are wanting to connect services in other programming languages it is easier to not have to deal with dynamic memory and just compute the size beforehand.

from glaze.

alan0526 avatar alan0526 commented on August 27, 2024

thanks

from glaze.

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.