Giter Site home page Giter Site logo

Comments (3)

vmg avatar vmg commented on July 19, 2024

let the codec release them once the wire-work has finished and the bytes are sent?

This is not safe to do at all because the wire-work in GRPC happens asynchronously in a background goroutine, so we never know when it's actually safe to return them to the pool. That's the reason why it hasn't been implemented for GRPC while we do have this feature for other systems like DRPC.

You can find on the internet several approaches to accomplish this (e.g. http://www.golangdevops.com/2019/12/31/autopool/) but none of them seem particularly reliable. An efficient implementation of memory pooling in GRPC would require upstream changes.

from vtprotobuf.

jzelinskie avatar jzelinskie commented on July 19, 2024

If there's no safe way to return a request to the pool, there's not much of a point to pooling unless you're allocating and returning messages elsewhere in your program?

from vtprotobuf.

steve-gray avatar steve-gray commented on July 19, 2024

I suspect there's a few things that could be done in this scenario. It strikes me that if the _grpc.pb.go generator was likewise customised, it could be made to:

  • Create the objects for requests/response from the VT Proto pooling
  • Use a runtime finalizer to release them.
  • When an object is returned over the wire from the invoke that object itself, if it implements the VT Pooling interfaces could be then runtime finalized too (so as long as the person generating the response object, pulled it from the pool).

This would be safe, right? Kind of feeling @jzelinskie's vibe that the pooling isn't much use without this. We're using it for some places that use protobuf for internal data representations, but it feels like a lot of the value is being left on the cutting room floor a bit.

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.