lvlbp

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 3 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(capacity int) *[]byte

Get returns byte slice with the given capacity.

func Put

func Put(b *[]byte)

Put returns byte slice to the pool.

func Stats

func Stats() ([17]int64, int64)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL