News for hackers. Stuff that matters.
Re:Disruptor: High performance alternative to bounded queues... by ahoka on Friday July 08, 2016 @10:56AM (#12055962)
What you are missing is that with the disruptor pattern you can do this lock-less while keeping the order: The producer gets a sequence number before accessing the space in the queue. This seqno guarantees the order of consumption so there will be no reordering of events on the consumer side. After creating the message, the producer commits this id. Meanwhile the consumer waits for the next seqno to become committed and consumes it.

I have implemented a multiple producer, single consumer variant in C for logging and it works quite well. Loggers can write their message concurrently to the ring buffer, but the order will be correct in the log file.

Re:Disruptor: High performance alternative to bounded queues... by infamouscow on Friday July 08, 2016 @11:37AM (#12056255)
Sounds exactly what Concurrency Kit already does. http://concurrencykit.org/
Re:Disruptor: High performance alternative to bounded queues... by newobj on Friday July 08, 2016 @02:00PM (#12057455)
"Already does"? They're both from 2011. Even if they both do the same thing, do you have a point?
Re:Disruptor: High performance alternative to bounded queues... by therestisgone on Friday July 08, 2016 @11:55AM (#12056406)
Except Concurrency Kit only supports a single producer.
Re:Disruptor: High performance alternative to bounded queues... by mej10 on Friday July 08, 2016 @01:28PM (#12057207)
The paper linked says that the most common use of Disruptor only has one producer.
Re:Disruptor: High performance alternative to bounded queues... by irishjohnnie on Friday July 08, 2016 @04:20PM (#12058362)
IIRC, the data structure that they used was not thread-safe. There eventually had to be an interlocked compare exchange operation which slowed throughput. Also, I couldn't imagine this working correctly in out-of-order cores without memory barriers at the very least.
Re:Disruptor: High performance alternative to bounded queues... by ahoka on Saturday July 09, 2016 @04:01AM (#12060621)
Yes, you need to use CAS and barriers to make it thread safe. I have also used a condvar for the consumer to avoid spinning while waiting for log messages.