Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicate tasks slice pool causes heap allocation #75

Closed
ijsong opened this issue Aug 25, 2022 · 0 comments · Fixed by #416 or #404
Closed

Replicate tasks slice pool causes heap allocation #75

ijsong opened this issue Aug 25, 2022 · 0 comments · Fixed by #416 or #404
Assignees

Comments

@ijsong
Copy link
Member

ijsong commented Aug 25, 2022

Reclaiming replicate tasks slice to the pool causes unnecessary heap allocations since the type of argument in sync.(*Pool).Put is an interface.
We need to convert the type of pool element from slice to pointer type.

ijsong added a commit that referenced this issue Aug 25, 2022
It skips lint warnings related to #73, #74, and #75.
ijsong added a commit that referenced this issue Apr 13, 2023
The `replicateTaskSlicePool` pooled slices of `replicateTask`. The function
`releaseReplicateTaskSlice` received borrowed slice and then put it into `replicateTaskSlicePool`.
However, the `sync.(Pool).Put` parameter is an interface, so the slice escaped to the heap
unnecessarily.

Not to use unnecessary heap objects, this PR wraps the `replicateTask` slice with the struct
replicateTaskSlice.

Resolves #75
@ijsong ijsong self-assigned this Apr 13, 2023
ijsong added a commit that referenced this issue Apr 13, 2023
The `replicateTaskSlicePool` pooled slices of `replicateTask`. The function
`releaseReplicateTaskSlice` received borrowed slice and then put it into `replicateTaskSlicePool`.
However, the `sync.(Pool).Put` parameter is an interface, so the slice escaped to the heap
unnecessarily.

Not to use unnecessary heap objects, this PR wraps the `replicateTask` slice with the struct
replicateTaskSlice.

Resolves #75
ijsong added a commit that referenced this issue Apr 15, 2023
The `replicateTaskSlicePool` pooled slices of `replicateTask`. The function
`releaseReplicateTaskSlice` received borrowed slice and then put it into `replicateTaskSlicePool`.
However, the `sync.(Pool).Put` parameter is an interface, so the slice escaped to the heap
unnecessarily.

Not to use unnecessary heap objects, this PR wraps the `replicateTask` slice with the struct
replicateTaskSlice.

Resolves #75
ijsong added a commit that referenced this issue Apr 15, 2023
### What this PR does

The `replicateTaskSlicePool` pooled slices of `replicateTask`. The function
`releaseReplicateTaskSlice` received borrowed slice and then put it into `replicateTaskSlicePool`.
However, the `sync.(Pool).Put` parameter is an interface, so the slice escaped to the heap
unnecessarily.

Not to use unnecessary heap objects, this PR wraps the `replicateTask` slice with the struct
replicateTaskSlice. 

### Which issue(s) this PR resolves

Resolves #75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant