Documentation
¶
Overview ¶
Package bufpool provides buffer pools for reducing GC pressure in hot paths.
Two pool sizes are provided:
- SmallPool (64 bytes): For index keys, serial encoding, short buffers
- MediumPool (1KB): For event encoding, larger serialization buffers
Usage:
buf := bufpool.GetSmall() defer bufpool.PutSmall(buf) // Use buf... // IMPORTANT: Copy buf.Bytes() before Put if data is needed after
Index ¶
Constants ¶
const ( // SmallBufferSize for index keys (8-64 bytes typical) SmallBufferSize = 64 // MediumBufferSize for event encoding (300-1000 bytes typical) MediumBufferSize = 1024 )
Variables ¶
This section is empty.
Functions ¶
func CopyBytes ¶
CopyBytes copies the buffer contents to a new slice. Use this before returning the buffer to the pool if the data needs to persist.
func GetMedium ¶
GetMedium returns a medium buffer (1KB) from the pool. Call PutMedium when done to return it to the pool.
WARNING: Copy buf.Bytes() before calling PutMedium if the data is needed after the buffer is returned to the pool.
func GetSmall ¶
GetSmall returns a small buffer (64 bytes) from the pool. Call PutSmall when done to return it to the pool.
WARNING: Copy buf.Bytes() before calling PutSmall if the data is needed after the buffer is returned to the pool.
func PutMedium ¶
PutMedium returns a medium buffer to the pool. The buffer is reset before being returned.
Types ¶
This section is empty.
Source Files
¶
- pool.go