Giter Site home page Giter Site logo

Comments (4)

coxley avatar coxley commented on August 18, 2024

Ah, I see this is mentioned in #8 and #63.

@nockty: [We] need further information to tackle this issue. Namely, a benchmark showing that individually pooling objects can be more performant in certain scenarios.

Not sure if it helps, but in my use-case I can't decode the entire object at once.

The children objects reside as bytes in a ton of BigTable cells. The parent is only initialized after the children have finished decoding in-full. Pooling the children makes sense for us because these decodes have to be done separately as each result is read.

The best place to release everything is once the parent is no longer needed — thus recursive return being ideal for us.

from vtprotobuf.

vmg avatar vmg commented on August 18, 2024

The finalizers approach is IMO out of the question because they perform horribly in Go. I do agree this is a bit of a footgun in the pooling API, and it may not be enough to clarify the documentation. I think the recursive release would be the safest API we can provide, but I get the feeling it will require quite a bit of code. 😓

from vtprotobuf.

coxley avatar coxley commented on August 18, 2024

To clarify, I wasn't suggesting those steps as part of the API. Just the only levers users currently have available. :)

from vtprotobuf.

HALO-04 avatar HALO-04 commented on August 18, 2024

Hi @vmg , I'm also interested in this topic. Can you please help me resolve my two small doubts?

  1. Does the phrase recursive release means generating code liking this:
func (m *Foo) ResetVT() {
	for _, mm := range m.Bars {
		// mm.ResetVT()
                mm.ReturnToVTPool()        // if mm is poolable, use ReturnToVTPool instead of ResetVT
	}
	f0 := m.Bars[:0]
	m.Reset()
	m.Bars = f0
}
  1. Will pooling for map type be supported in the future? I think this might bring the benefits like reusing slice
message Foo {
  option (vtproto.mempool) = true;
  map<int64, Bar>  barsMap = 1;
}

message Bar {
  option (vtproto.mempool) = true;
}
func (m *Foo) ResetVT() {
        keysToDelete := []int64{}
	for key, value := range m.BarsMap {
                value.ReturnToVTPool()                                       // only put the values in sync.Pool
                keysToDelete = append(keysToDelete, key)
	}
        for _, key := range keysToDelete {
                delete(m.BarsMap, key)
        }
	f0 := m.BarsMap
	m.Reset()
	m.BarsMap = f0
}

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.