Leveled byte pool. Inspired by VictoriaMetrics.
Instead of having 1 pool for byte slices, we create multiple pools that are serving slices of a particular size. This reduces overhead for the smaller slices, because they will not be resized when we request for the bigger slices. Also library provides stats to see how many allocations do we have for each class.
go get github.com/cristalhq/lvlbp
size := 42
bb := lvlbp.Get(size)
defer lvlbp.Put(bb)
// do something with bb of size `closestPowerOf2(42)`
See these docs.