smallobjectpool

Crates.iosmallobjectpool
lib.rssmallobjectpool
version0.1.3
sourcesrc
created_at2024-07-28 18:06:32.806666
updated_at2024-08-03 16:53:30.606704
descriptionA small object pool for Rust
homepagehttps://github.com/jmelo11/smallobjectpool
repositoryhttps://github.com/jmelo11/smallobjectpool
max_upload_size
id1318141
size30,544
Jose Melo (jmelo11)

documentation

README

SmallObjectPool

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.

Usage

use smallobjectpool::SmallObjectPool;

fn main() {
    let mut sop = SmallObjectPool::<u32, 4>::new();
    for i in 0..8 {
        sop.push(i);
    }
}

Performance

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

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Commit count: 0

cargo fmt