MPMC queue for passing raw bytes

99 views
Skip to first unread message

Вадим Кайнаров

unread,
Sep 5, 2023, 12:04:17 AM9/5/23
to Scalable Synchronization Algorithms
Hi all,

Here is the bounded MPMC queue that allows chunks of "arbitrary" size to pass through it. I have two minor questions:

1. Does it Make Sense?
The idea is that this approach could sometimes be more convenient than using pointers, as it eliminates the need to allocate and deallocate memory on the fly.
Furthermore, we often start with raw data (e.g., received from a network) to process.

2. Does it Work?
a) gcc-11.4 with tsan shows warnings, even though the tests pass. On the other hand, with clang-15, tsan is happy.
Could these warnings be false positives, or have I overlooked some kind of bug or fundamental issue?

b) The implementation can suffer from the ABA when the meta_idx counter wraps around twice while a thread is stale.
That's why, in tests, only the SPSC case is presented when Atom == uint8_t.
While this is more of a theoretical problem for uint64_t, it could potentially occur in practice for uint32_t because some bits are allocated for data_idx.
Is there any remedy against it?
Reply all
Reply to author
Forward
0 new messages