r/cpp • • Mar 24 '26

Optimizing a Lock-Free Ring Buffer

https://david.alvarezrosa.com/posts/optimizing-a-lock-free-ring-buffer/
104 Upvotes

58 comments sorted by

View all comments

Show parent comment

4

u/Big_Target_1405 Mar 25 '26 edited Mar 25 '26

You can actually exceed the performance (particularly latency and jitter) of the rigtorp queue without caching head/tail. Caching head/tail optimises for the wrong thing (non-empty queues i.e. throughout)

1

u/skebanga Mar 25 '26

Care to share details?

5

u/Bart_V Mar 25 '26

Caching is faster on average, when you measure total time of many operation. However, since you do more work on each push and pop, the worst case time per operation (latency) is longer. And for instance on real time systems you're more interested in optimizing worst case latency than throughput.