Skip to content

Conversation

Danthar
Copy link
Member

@Danthar Danthar commented Aug 9, 2017

close #2649

Fix for stashing support in priority mailbox.

@Danthar Danthar added this to the 1.3.0 milestone Aug 9, 2017
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on the implementation yet... It's not as trivial of a fix as it appears IMHO.

ReceiveAny(msg =>
{
var sender = Sender;
var testActor = _testkit.TestActor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just pass in an IActorRef instead of doing this stuff with the TestKit in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test actor was a quick copy paste from the EchoActor in the Testkit. But your right. It could be done simpler

@@ -14,9 +15,11 @@ namespace Akka.Dispatch.MessageQueues
/// <summary>
/// Base class for a message queue that uses a priority generator for messages
/// </summary>
public class UnboundedPriorityMessageQueue : BlockingMessageQueue
public class UnboundedPriorityMessageQueue : BlockingMessageQueue, IUnboundedDequeBasedMessageQueueSemantics
Copy link
Member

@Aaronontheweb Aaronontheweb Aug 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the fence about this - it definitely adds deque semantics to the mailbox, but I'm now left wondering if we should be allowing stashing to work with the priority mailboxes in the first place.

If I think about it, the entire point of the prioritymailbox is to process messages in the order of the priority generator. FIFO no longer takes hold once you allow prioritization (across messages with different priorities - the StablePriorityMailbox should allow FIFO to occur within a priority.) So what good is stashing then? If I unstash a message I couldn't previously process, it either gets pushed back onto the queue in a totally different order (possibly not getting processed next) or if we stick with our normal double-ended queue semantics, it doesn't get processed in its normal priority order again.

I dunno, I'm leaning towards telling the users "don't use priority mailboxes with stashing." Either we just re-add messages we can't process back into the priority queue and re-prioritize them, which doesn't let us preserve message order (the re-added message will appear to be newer) or maybe we have to rewrite the prepend buffer to behave like a priority queue as well and process that first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right. It does add some wierd semantics to the whole thing. I asked around on jvm akka channel about this. But haven't gotten any response as of yet.

The way this works now, is that messages are enqueued in the priority queue first. Then are handled by the actor, and then are stashed. Which means that messages are stashed in the order of priority as initially determined. When you unstash all, they are fed to the actor in that order as well.

This makes for some wierd behavior. Because it would seem to work when you simply stash all messages, and unstash all at a certain point. (see the spec i added as an example). But ofcourse this breaks down if you only intermittently stash and unstash a message.

Changing the prepend buffer to a priority queue wont solve this either. As that would mean the order would only be guarenteed within the context of the stashed messages, and not the mailbox in itself (the buffer of messages waiting will not be taken into account when determining priority)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I think my final thoughts on the subject are: let the users worry about their message orders. If they want to use stashing and priority mailboxes where the results aren't 100% predictable or stable, that's up to them.

Having 50*3 messages expected to be processed in 300ms caused the spec
to fail.
Surprisingly upping timeout to 30 secs isnt enough. So i lowered the
workload instead
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@@ -14,9 +15,11 @@ namespace Akka.Dispatch.MessageQueues
/// <summary>
/// Base class for a message queue that uses a priority generator for messages
/// </summary>
public class UnboundedPriorityMessageQueue : BlockingMessageQueue
public class UnboundedPriorityMessageQueue : BlockingMessageQueue, IUnboundedDequeBasedMessageQueueSemantics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I think my final thoughts on the subject are: let the users worry about their message orders. If they want to use stashing and priority mailboxes where the results aren't 100% predictable or stable, that's up to them.

@Aaronontheweb Aaronontheweb merged commit 3e1b5c2 into akkadotnet:v1.3 Aug 10, 2017
@Danthar Danthar deleted the issue-2649 branch August 11, 2017 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants