Comments (4)
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.
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.
To clarify, I wasn't suggesting those steps as part of the API. Just the only levers users currently have available. :)
from vtprotobuf.
Hi @vmg , I'm also interested in this topic. Can you please help me resolve my two small doubts?
- 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
}
- 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)
- Uncompilable code generated for repeated groups
- Duplicated code generated for GRPC client/server HOT 1
- Panic after WKT commit: assignment to entry in nil map HOT 2
- Extensions are not encoded
- bug: oneof field that includes bytes field yields invalid ResetVT method
- Supporting Embedded and Nullable features from gogo proto HOT 2
- bug: Broken ResetVT generation for optional message HOT 1
- bug: grpc client methods does not use qualified idents
- feature: poolable messages paths with wildcard HOT 2
- unmarshal_unsafe feature produced code does not compile: "Cannot use intStringLen (type int) as the type IntegerType" HOT 1
- Run vtproto multiple times on different files of the same package HOT 3
- bug: IsMap not checked on message field's ReturnToVTpool
- bug: UnmarshalUnsafe panics when map values are empty strings HOT 2
- Request for New Release that Includes Well-Known Type Support HOT 4
- gRPC codec has different semantic on Unmarshal than the default one HOT 1
- v0.6.0 is creating issues in ubuntu20 HOT 2
- Offering assistance and discussing upkeep / releases for vtprotobuf HOT 8
- wrong pool unmarshal slize HOT 3
- Add optional unsafe operations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vtprotobuf.