Also would numberOfMessages and hasMessages also be called from only one thread at a time?
On Tuesday, April 30, 2013 10:16:03 AM UTC-7, Rajiv Kurian wrote:I am trying to use a ring buffer from the Disruptor framework(https://github.com/LMAX-Exchange/disruptor) to implement a bounded mailbox for an Akka actor as an experiment. The Disruptor framework uses a ring buffer as a pseudo queue structure between multiple producers (whose inserts will be serialized) and parallel consumers who could be serially processing different sections of the ring buffer.From reading the Akka docs it seems like the way to create a custom mailbox like this is to extend the MessageQueue trait. If my understanding is correct all the methods (enqueue, dequeue, numberOfMessages, hasMessages) etc need to support concurrent calls. I am hoping to just use disruptor's producer barrier feature to implement concurrent enqueue.As for the dequeue since the actor is the one calling it am I right to assume that only one thread at a time could call dequeue? The reason I am asking is that I could then implement the consumer sequence number as a simple volatile primitive. A thread could call dequeue and it would increment this sequence number. Subsequent dequeues on the same thread (in case of batch processing) would all increment the sequence number without any race. When the actor is suspended and resumed on another thread it would still see the latest sequence number without a race.
I apologize for the Disruptor jargon and the messed up Akka jargon too. Hoping some of you guys have tried out the Disruptor framework.
Thanks for the reply Roland. I haven't played with either. I am hoping to learn about it from this experiment. They have some staggering numbers for the single producer use case compared to concurrent queues, which sadly can't be used for the actor api. Their latest release benchmarks boast of 220M ops/sec for a single producer use case on an i7 Ivy Bridge @ 3.4 GHz. Multiple producers benchmark is at about 15 M ops/sec. The ring buffer though has to be of a fixed size so I can't think of a way to use it for an unbounded mailbox in a performant way.
If somebody is still interested, I've implemented a bounded mailbox using Disruptor and obtained a throughput gain of about 50% over the standard bounded mailbox. You can find the source code here https://github.com/yngui/akka-disruptor.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
Interesting!
What unbounded mailbox impl did you use?
Hi Igor,
Looks very competetive :-)