ringbuf icon indicating copy to clipboard operation
ringbuf copied to clipboard

Performance vs other crates?

Open TheButlah opened this issue 4 years ago • 3 comments

A basic performance comparison would be great to compare against other rust ringbuffers, as well as crossbeam channel.

TheButlah avatar Apr 11 '21 03:04 TheButlah

See also https://github.com/mgeier/rtrb/issues/39.

mgeier avatar Apr 11 '21 09:04 mgeier

Hi, thank you for being interested in this crate!

Honestly speaking, the performance wasn't the main goal of the crate and I haven't focused on it heavily. I created that crate just to have at least some implementation of ring buffer being light-weight and with direct access to underlying memory. And I'm glad to see that now there is a variety of a ring buffer implementations to choose from.

About your question - @mgeier made a nice comparison and according to it rtrb seems to be a better option.

It's interesting to find out where 3x performance difference come from. Maybe in near future I will find some time to investigate this and to apply some optimizations.

agerasev avatar Apr 14 '21 16:04 agerasev

It's interesting to find out where 3x performance difference come from.

I guess a part of it comes from false sharing of the head and tail indices as suggested in #7.

https://github.com/agerasev/ringbuf/issues/7#issuecomment-666339687 mentions another potential optimization by trying to read the atomic indices less often.

mgeier avatar Apr 22 '21 08:04 mgeier