planetscale / planetscale/vtprotobuf
Question about behavior of `ReturnToVTPool()` and `Reset()`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Using this proto:
message Parent {
option (vtproto.mempool) = true;
repeated Child children = 1;
Child one = 2;
}
message Child {
option (vtproto.mempool) = true;
uint32 field = 1;
}
When calling ReturnToVTPool() on Parent it calls ResetVT on all children and then calls m.Reset()
func (m *Parent) ResetVT() {
for _, mm := range m.Children {
mm.ResetVT()
}
m.One.ReturnToVTPool()
m.Reset()
}
However m.Reset() allocates a new object and overwrites the existing object entirely:
func (x *Parent) Reset() {
*x = Parent{}
This nils out all fields on the parent throwing away the slice for the GC to handle. Am I missing something? Is there some way to put back into the pool, call ResetVT() but not call Reset()?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the generated Parent.ResetVT and ReturnToVTPool methods for the proto shown, then compare their behavior with Parent.Reset and the child pooling calls. Determine the intended reset and slice-retention semantics, and define completion as an agreed behavior backed by a regression test or documented explanation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100