Stele
Stele is a Single Writer, Many Reader append-only concurrent data structure with opt-in support for no_std and the Allocator API
How does it work?
Stele is, in essence, an array of exponentially larger arrays, where the nth element of the outer array holds 2n elements. This is accomplished by taking a given index and splitting it in to two indices:
-
An outer index that is the log2 of the index rounded down. This is which outer array pointer holds the requested data.
-
An inner index that is the difference of the input index and the outer index. This is the offset from the pointer given by the outer array to the element pointed to by the index.
This allows us to use the whole usable address space of a given architecture without needing to copy the data from the old location to the new location on each new allocation.
The tradeoff is memory usage, as the data structure has to hold an array of pointers equal to the address width of the processor. For example, on a 64 bit system, the outer array holds 64 8-byte pointers, using 512 bytes of memory, even without any allocation.
How do I use it?
use thread;
use ;
Minimum Supported Rust Version (MSRV)
-
Without the allocator api, MSRV is 1.64
-
As of 2023-03-12, the allocator api requires nightly and does not have a stable version. Once the allocator api is supported on stable this will be replaced with said stable version