logoalt Hacker News

Building a Fast Lock-Free Queue in Modern C++ from Scratch

22 pointsby ibobevlast Wednesday at 2:58 PM3 commentsview on HN

Comments

nlytoday at 12:50 PM

Once you use atomic cmpxchg you've lost a great deal of scalability because it implies a retry loop (internal or by the user)

The last thing you want is all of the threads failing to cmpxchg (spuriously or otherwise ) spinning on a shared cacheline

Real world alternatives show atomic xchg only solutions scale to hundreds of threads.

rfgplktoday at 12:22 PM

Nice article. There a few issues with your code however from a cursory glance; your dtor seems to allow for spurious/double frees due to custom deleter support (you wanna check up on that), you also seem to use seq_cst far too much even if not needed (you want to avoid them is queues as much as possible), lastly class FastQueueNodeSlot.. isn't aligned (plus 64b alignment is only a thing for amd64 cpus, apple silicon is larger).

PcChiptoday at 12:50 PM

Is this similar to moodycamel’s?