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

Pool allocate arrays instead of slices #53

Closed
wants to merge 5 commits into from

Conversation

H1JK
Copy link
Contributor

@H1JK H1JK commented Nov 18, 2023

This is inspired by https://go-review.googlesource.com/c/net/+/539915

This remove the allocation for the slice header in sync.Pool.New and putDataBufferChunk.
It also divide the number of allocations kept alive by the pool.

Because Go interfaces are optimized with pointer values, this would also remove 1 alloc in Get() and make buffer put-and-get process zero-alloc.

The binary size may increase by about 7KB as a trade-off, but the execution speed is slightly improved.

@nekohasekai
Copy link
Member

Merged in ed23253 and a5c920a

@nekohasekai nekohasekai closed this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants