Skip to content

cristalhq/lvlbp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lvlbp

build-img pkg-img reportcard-img coverage-img

Leveled byte pool. Inspired by VictoriaMetrics.

Rationale

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.

Install

go get github.com/cristalhq/lvlbp

Example

size := 42
bb := lvlbp.Get(size)
defer lvlbp.Put(bb)

// do something with bb of size `closestPowerOf2(42)`

Documentation

See these docs.

License

MIT License.