Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persisent concurrent shared composable element pools
By popular demand, this provides a code generator for persistent concurrent shared composable elements pools. This is a building block for more advanced concurrent data structures that have been requested. From fd_pool_para.c: Generate prototypes, inlines and/or implementations for concurrent persistent element pools. A pool can hold a practically unbounded number of elements. Acquiring an element from and releasing an element to a pool are typically fast O(1) time. Requires small O(1) space per element. The current implementation is based on a lockfree stack. Acquire and release are done via atomic compare-and-swap of the stack top. As such, concurrent usage requires FD_HAS_ATOMIC support (this can still be used on platforms without FD_HAS_ATOMIC support but it will not be safe for concurrent usage). Stack top versioning is used to handle ABA. Versioning has been been tweaked to support locking global pool operations like initialization (and thus, this can also be used without changes as a more conventional spin lock based concurrent stack). Unsurprisingly, the current implementation is equally usable as a concurrent element stack (though the implementation may be changed in the future to better support ultra high contention ultra high concurrency like fd_alloc). The current implementation is optimized for pools with a moderate number of reasonably localized users (e.g. a handful of cores and memory on the same NUMA node). Various operations are slightly more optimal when the size of a pool element is an integer power of 2. Operations do much internal integrity checking / bounds checking for use in high reliability / high security environments. This API is designed for tight and flexible composition with treaps, heaps, lists, maps, etc. Further, a pool can be persisted beyond the lifetime of the creating process, be used inter-process, be relocated in memory, be naively serialized/deserialized, be moved between hosts, use index compression for cache and memory bandwidth, etc. See fd_pool_para.c for more details.
- Loading branch information