Hi Igor,

you are right concerning the default dispatcher, but BalancingDispatcher (as 
you note) and some Routers also use hasMessages—as could custom dispatchers. 
Therefore this mailbox implementation is a specialized one, it does not 
implement the full interface so to speak. Could it be made to obey the full 
contract without losing the performance benefits?

Regards,

Roland

6 jan 2014 kl. 11:34 skrev Igor Konev <[email protected]>:

> Hi Roland,
> 
> Although you mentioned above that hasMessages is called upon every tell 
> operation, it looks like it is not the case. Not taking BalancingDispatcher 
> into account hasMessages is called from Mailbox's canBeScheduledForExecution 
> as follows
> 
>   final def canBeScheduledForExecution(hasMessageHint: Boolean, 
> hasSystemMessageHint: Boolean): Boolean = status match {
>     case Open | Scheduled ⇒ hasMessageHint || hasSystemMessageHint || 
> hasSystemMessages || hasMessages
>     case Closed           ⇒ false
>     case _                ⇒ hasSystemMessageHint || hasSystemMessages
>   }
> 
> But hasMessages and hasSystemMessageHint are never false at the same time 
> when canBeScheduledForExecution is called (indirectly) from Dispatcher:
> 
>   protected[akka] override def registerForExecution(mbox: Mailbox, 
> hasMessageHint: Boolean, hasSystemMessageHint: Boolean): Boolean = {
>     if (mbox.canBeScheduledForExecution(hasMessageHint, 
> hasSystemMessageHint)) { //This needs to be here to ensure thread safety and 
> no races
>       ...
> 
>   protected[akka] def dispatch(receiver: ActorCell, invocation: Envelope): 
> Unit = {
>     val mbox = receiver.mailbox
>     mbox.enqueue(receiver.self, invocation)
>     registerForExecution(mbox, true, false)
>   }
> 
>   protected[akka] def systemDispatch(receiver: ActorCell, invocation: 
> SystemMessage): Unit = {
>     val mbox = receiver.mailbox
>     mbox.systemEnqueue(receiver.self, invocation)
>     registerForExecution(mbox, false, true)
>   }
> 
> So hasMessages is never called upon tell.
> 
> пятница, 3 января 2014 г., 10:51:33 UTC+2 пользователь rkuhn написал:
> Hi Igor, 
> 
> thanks for sharing! On first (cursory) sight it looks like your mailbox might 
> cause missed wake-ups because head and tail are read by the enqueueing thread 
> without synchronization (i.e. disruptor cursor is moved but updates to head 
> and tail have not been published; this might be mitigated by clever ordering 
> of effects, but my spidey senses make me uneasy on this one). 
> 
> Regards, 
> 
> Roland 
> 
> 1 jan 2014 kl. 20:04 skrev Igor Konev <[email protected]>: 
> 
> > 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 [email protected]. 
> > To post to this group, send email to [email protected]. 
> > Visit this group at http://groups.google.com/group/akka-user. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> 
> 
> 
> Dr. Roland Kuhn 
> Akka Tech Lead 
> Typesafe – Reactive apps on the JVM. 
> twitter: @rolandkuhn 
> 
> 
> 
> -- 
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn


-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to