crossbeam icon indicating copy to clipboard operation
crossbeam copied to clipboard

Is there any interest in adding Coalescing Ring Buffer to crossbeam?

Open mmrath opened this issue 6 years ago • 6 comments

Something like https://github.com/LMAX-Exchange/LMAXCollections

mmrath avatar Feb 20 '19 22:02 mmrath

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?

ghost avatar Feb 21 '19 08:02 ghost

yes coalescing feature is what I am looking after.

mmrath avatar Feb 21 '19 17:02 mmrath

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 avatar Feb 24 '19 11:02 mmrath

@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?

ghost avatar Feb 24 '19 12:02 ghost

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.

mmrath avatar Feb 24 '19 12:02 mmrath

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.

mmrath avatar Feb 24 '19 12:02 mmrath