https://github.com/dpc/recycle-rs
Simple allocated buffers reuse for Rust
https://github.com/dpc/recycle-rs
Last synced: 11 months ago
JSON representation
Simple allocated buffers reuse for Rust
- Host: GitHub
- URL: https://github.com/dpc/recycle-rs
- Owner: dpc
- Created: 2016-09-10T06:06:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-10T22:00:46.000Z (over 9 years ago)
- Last Synced: 2025-07-05T20:56:06.512Z (11 months ago)
- Language: Rust
- Size: 2.93 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Recycle - recycle owned values to avoid allocating
Status: just a prototype to benchmark the idea
In places where allocating is unavoidable. eg. when having to return `String`
or `Vec` from a function, return `Recycle` or `Recycle>`
and reuse the allocated values using thread-local pools.
```
test alloc_write_vec … bench: 74 ns/iter (+/- 4)
test alloc_write_recycle_vec … bench: 46 ns/iter (+/- 4)
test alloc_vec_u8 … bench: 22 ns/iter (+/- 1)
test recycle_vec_u8 … bench: 14 ns/iter (+/- 1)
test alloc_vec_u64 … bench: 23 ns/iter (+/- 1)
test recycle_vec_u64 … bench: 14 ns/iter (+/- 1)
```
I've found other library addressing same problem:
https://github.com/frankmcsherry/recycler , but I think this syntax is much
simpler to use.
`Recycle` implements `Deref` and `DerefMut`, and could potentially be
implemented for multiple more types, and interact well with `Into` `AsRef`
etc.