mirror of
https://github.com/tailscale/tailscale.git
synced 2026-10-23 03:37:19 +09:00
A naive sync.Pool that stores dynamically sized []byte is incorrect since the Pool assumes that each stored item carries approximately the same memory cost. Different cost items should be stored in different pools. The bufpool tracks buffer pools by powers of two and provides a Buffer type that mimics the API of bytes.Buffer. This is a performance optimization. Avoid using this unless there is a clear performance gain for doing so. Incorrect use can lead to widespread data corruption (as is already the case with any incorrect sync.Pool use). Updates tailscale/corp#21363 Signed-off-by: Joe Tsai <joetsai@digital-static.net>