capnproto / go-capnp

Cap'n Proto library and code generator for Go
https://capnproto.org
Other
1.22k stars 110 forks source link

bufferpool: Switch to zeropool #555

Closed matheusd closed 5 months ago

matheusd commented 8 months ago

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.