crossbeam
crossbeam copied to clipboard
Is there any interest in adding Coalescing Ring Buffer to crossbeam?
Something like https://github.com/LMAX-Exchange/LMAXCollections
Yes, we want to add something like this. Questoin: are you interested in the coalescing feature of CoalesingRingBuffer (overwriting values with the same key) or only need a high-performance SPSC ring buffer?
yes coalescing feature is what I am looking after.
My attempt to create such a data structure is at https://github.com/mmrath/coalescing_buffer I am not 100% sure about the unsafe usage and the atomic primitives used there. I think a rewritten version would generally use AtomicCell from this project.
@mmrath Everything looks good on a quick look!
By the way, since each offer operation needs to iterate through all elements, does that make them costly? My intuition would be that the capacity of coalescing buffers would typically be relatively small - is that true? What is the ballpark number of a reasonable capacity for most real world uses?
For my use case it would be less than 200. I have used it for Forex rates. Sometimes I use multiple instances but generally not a big one.
Also most of the time the buffer would closer to zero size so linear search is helpful. When there is a big stream of events it would grow but even then I think linear search would still be fast because of small size.