Skip to main content

Module buffer_pool

Module buffer_pool 

Source
Expand description

§Buffer Pool

Object pool for frequently allocated small buffers (<4KB) to reduce allocation overhead in high-throughput scenarios.

§Performance

  • 3-5% latency reduction under high load
  • Eliminates allocator contention for small buffers
  • Thread-safe with minimal lock contention

§Usage

use network_protocol::utils::buffer_pool::BufferPool;

let pool = BufferPool::new(100); // 100 buffers in pool
let mut buffer = pool.acquire();
// Use buffer...
// Buffer automatically returned to pool on drop

Structs§

BufferPool
Thread-safe buffer pool for small allocations
PooledBuffer
A pooled buffer that returns itself to the pool when dropped