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

bufferpool: Switch to zeropool #555

Merged
merged 1 commit into from
Jun 1, 2024

Conversation

matheusd
Copy link
Contributor

@matheusd matheusd commented Mar 5, 2024

This commit switches the bufferpool to use the zeropool implementation for sync pools.

The stdlib sync.Pool implementation has an issue where it causes an additional heap allocation per Put() call when used with byte slices.

github.com/colega/zeropool package has been specifically designed to work around this issue, which reduces GC pressure and improves performance.

This also fixes the bufferpool's pkg benchmark to use a new pool per test, to avoid other tests influencing the behavior of the benchmark and sets it to report the allocations.

This commit switches the bufferpool to use the zeropool implementation
for sync pools.

The stdlib sync.Pool implementation has an issue where it causes an
additional heap allocation per Put() call when used with byte slices.

github.com/colega/zeropool package has been specifically designed to
work around this issue, which reduces GC pressure and improves
performance.

This also fixes the bufferpool's pkg benchmark to use a new pool per
test, to avoid other tests influencing the behavior of the benchmark and
sets it to report the allocations.
@matheusd matheusd mentioned this pull request Apr 5, 2024
@lthibault lthibault self-requested a review June 1, 2024 01:07
Copy link
Collaborator

@lthibault lthibault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I've been mildly annoyed with sync.Pool's heap allocs for quite a while, so thank you for introducing me to this great little library.

@lthibault lthibault merged commit 2d1c565 into capnproto:main Jun 1, 2024
@matheusd matheusd deleted the switch-to-zeropool branch June 3, 2024 10:11
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