Giter Site home page Giter Site logo

Comments (4)

jacobmarble avatar jacobmarble commented on July 19, 2024

I notice that, for non-repeated message fields, ReturnToVTPool() is called by the parent's ResetVT() method. Repeated fields do not receive this treatment, however.

from vtprotobuf.

jacobmarble avatar jacobmarble commented on July 19, 2024

It seems the idea is that a nested message structure should be pooled only at the top level parent. Repeated fields are cleared by ResetVT(), but their contents (pointers to other messages) are not pooled, even if the repeated child message definition is marked as such.

from vtprotobuf.

vmg avatar vmg commented on July 19, 2024

Hey @jacobmarble! What you're seeing is an optimization for repeated fields with pooled messages: when clearing a repeated field, instead of returning every single message to the pool, what we do is leaving them in the non-addressable part of the slice (i.e. into its capacity). This way, when unmarshaling again into the same message, instead of append-ing to a zero-length slice, we can check if the current unaddressed capacity for the message contains messages, and if so, use those by simply growing the addressable length of the slice.

For every single benchmark I've been able to synthesize, this is always significantly faster than returning every single object to the pool (and then fetching from the pool when unmarshaling). Does this behavior surprise you, or is it breaking some of your expectations...?

from vtprotobuf.

jacobmarble avatar jacobmarble commented on July 19, 2024

@vmg thanks for explaining, I think I understand. The behavior does surprise me, but I'm not sure it's wrong.

from vtprotobuf.

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.