Expand description
Buffer pooling for message serialization/deserialization.
This module provides a thread-local buffer pool to reduce allocation overhead for message processing. Buffers are reused for messages under a size threshold, while larger messages get fresh allocations.
§Performance
- Small messages (< 64KB): Reused from pool, zero allocation
- Large messages (>= 64KB): Fresh allocation (rare case)
- Thread-local: No contention between threads
Structs§
- Pool
Stats - Buffer pool statistics.
- Pooled
Buffer - A pooled buffer that returns to the pool on drop.
Constants§
- DEFAULT_
BUFFER_ SIZE - Default buffer size (64 KB).
- MAX_
POOLED_ BUFFER_ SIZE - Maximum buffer size to pool (larger buffers are dropped).
- MAX_
POOL_ SIZE - Maximum number of buffers to keep in the pool per thread.
Functions§
- acquire
- Acquire a buffer from the pool with the given minimum capacity.
- acquire_
default - Acquire a buffer with the default size.
- clear_
pool - Clear the buffer pool for the current thread.
- pool_
stats - Get buffer pool statistics for the current thread.