Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cristalhq/lvlbp
Leveled byte pool
https://github.com/cristalhq/lvlbp
allocation allocator byte-slice dependency-free go golang memory-management performance pool
Last synced: 9 days ago
JSON representation
Leveled byte pool
- Host: GitHub
- URL: https://github.com/cristalhq/lvlbp
- Owner: cristalhq
- License: mit
- Created: 2021-07-28T15:47:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-24T13:54:57.000Z (over 3 years ago)
- Last Synced: 2024-11-06T07:09:49.852Z (about 2 months ago)
- Topics: allocation, allocator, byte-slice, dependency-free, go, golang, memory-management, performance, pool
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lvlbp
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![coverage-img]][coverage-url]Leveled byte pool. Inspired by [VictoriaMetrics](https://github.com/VictoriaMetrics/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
```go
size := 42
bb := lvlbp.Get(size)
defer lvlbp.Put(bb)// do something with bb of size `closestPowerOf2(42)`
```## Documentation
See [these docs][pkg-url].
## License
[MIT License](LICENSE).
[build-img]: https://github.com/cristalhq/lvlbp/workflows/build/badge.svg
[build-url]: https://github.com/cristalhq/lvlbp/actions
[pkg-img]: https://pkg.go.dev/badge/cristalhq/lvlbp
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/lvlbp
[reportcard-img]: https://goreportcard.com/badge/cristalhq/lvlbp
[reportcard-url]: https://goreportcard.com/report/cristalhq/lvlbp
[coverage-img]: https://codecov.io/gh/cristalhq/lvlbp/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/cristalhq/lvlbp