| Crates.io | smallobjectpool |
| lib.rs | smallobjectpool |
| version | 0.1.3 |
| created_at | 2024-07-28 18:06:32.806666+00 |
| updated_at | 2024-08-03 16:53:30.606704+00 |
| description | A small object pool for Rust |
| homepage | https://github.com/jmelo11/smallobjectpool |
| repository | https://github.com/jmelo11/smallobjectpool |
| max_upload_size | |
| id | 1318141 |
| size | 30,544 |
A rust implementation of a block list, a data structure described in the book "Modern Computational Finance: AAD and Parallel Simulations" by Antoine Savine. The repo contains the following implementations:
PtrBased: A trait that exposed methods to interact with data structures as if they were in C++ (i.e. using pointers and iterators).ArrayLike: A simple implementation of a list, using pointers.LinkedList: Linked-list, using pointers.SmallObjectPool: AKA "BlockList", a list of fixed-size blocks, using pointers.use smallobjectpool::SmallObjectPool;
fn main() {
let mut sop = SmallObjectPool::<u32, 4>::new();
for i in 0..8 {
sop.push(i);
}
}
In terms of performance, the SmallObjectPool achieves close performance to a Vec, but still the latter is faster. In this case, the benefit of the SmallObjectPool will come from a smaller footprint in memory, as it doesn't need to allocate memory for each element after the capacity is reached.
| Operation | Avg Time (ns or µs) | Outliers |
|---|---|---|
| vec push | 932.30 ns | None |
| array direct insert | 326.35 ns | 15 outliers (3 high mild, 12 high severe) |
| sop push | 18.534 µs | 17 outliers (9 low mild, 5 high mild, 3 high severe) |
| linked list push | 220.50 µs | 6 outliers (3 high mild, 3 high severe) |
| vec high volume push | 16.383 µs | None |
This project is licensed under the MIT License - see the LICENSE.md file for details.