0

Assume having a bounded MPMC queue (roughly something like this: https://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue). N threads are producers and M threads are consumers. All producers and consumers run on isolated cores and are pinned. So they never get interrupted.

N and M can be quite high and all those threads are working on the same atomic variables. Due to that (given the code), they might loop longer around if another thread was "faster".

Would it be beneficial if for enqueuing a back-off is used? E.g. when we realize in the compare-and-swap that another thread was faster, the code currently immediately tries again to enqueue the item. However, it would also be possible to add a back-off (a "spin-loop"). Would that theoretically be beneficial (=more throughput) or doesn't it have any benefits at all? E.g. contention would improve which might be better, but not sure if that helps for the throughput.

Thanks a lot

Kevin Meier
  • 2,339
  • 3
  • 25
  • 52

0 Answers0