Skip to main content

Module pool

Module pool 

Source
Expand description

Chunk buffer recycling.

A 100 GB transfer at 1 MiB chunks is 100k chunks, each needing a plaintext buffer and an output buffer. Allocating and freeing 200k multi-megabyte buffers hands the allocator a workload it will happily serve and then return to the OS, so the process spends its time in madvise/page faults instead of moving bytes. Recycling keeps a small fixed set of hot buffers instead.

Structsยง

BufPool
Fixed-capacity stack of reusable byte buffers.
ObjPool
A small stack of reusable objects, handed out to workers and returned when they finish.
Pooled
A buffer that returns itself to its pool when dropped.