Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActorTaskScheduler QueueTask for LongRunning #1410 #1470

Closed
wants to merge 2 commits into from

Conversation

Aaronontheweb
Copy link
Member

For @Zetanova

@Aaronontheweb
Copy link
Member Author

@JeffCyr mind taking a look at this issue while you're at it?

@JeffCyr
Copy link
Contributor

JeffCyr commented Dec 1, 2015

@Aaronontheweb Sure,

I think the TaskCreationOptions got mixed up here.

TaskCreationOptions.LongRunning is a hint that means:

Hey scheduler, I'm going to send you a task that may take quite some time to complete, you may want to execute my task on a dedicated thread instead of the ThreadPool to prevent a starvation of your precious threads.

The changes proposed by @Zetanova breaks the ActorTaskScheduler contract (which is to execute tasks in the actor context) by executing the LongRunning task with TaskScheduler.Default (and potentially starving the ThreadPool) outside the actor context (so the task may execute concurrently with other tasks or with other Receives, this is bad).

Concerning the AttachedToParent option in @Zetanova's commit, I think the flag is mixed up as well. I tried to explain this one in issue #1346. This flag is poorly documented and this is probably due to the fact that it is generally harmful or useless. The proposed change would allow concurrent execution of tasks in the actor context when this flag is specified, so it is bad.

I implemented the LongRunning flag in the refactoring of ActorTaskScheduler included in PR #1484, can you validate that it address your issue appropriately?

@rogeralsing
Copy link
Contributor

Completely agree with @JeffCyr, this PR breaks actor concurrency constraint due to TaskScheduler.Default

@JeffCyr
Copy link
Contributor

JeffCyr commented Dec 2, 2015

I just realized that my implementation of the LongRunning task is useless in PR #1484. I'm starting a thread just to send a msg in the actor mailbox, the task will still be executed on the actor's IScheduler.

I think there is no fix to this issue, the ActorTaskScheduler cannot satisfy the LongRunning hint by design.

Do you think we should throw an exception and refuse to execute LongRunning tasks on an ActorTaskScheduler? I'm not sure what is the best trade-off here, it could work to just ignore the flag too.

My opinion is that it should behave like a UI thread which ignore the LongRunning flag, the UI would potentially freeze if the task is infinite and the programmer would realize that he must not execute long running tasks in message pump.

@rogeralsing
Copy link
Contributor

I think ignoring the flag would be the most correct thing to do, as that is inline with how other schedulers work as you describe.

The fact that actors shouldn't do long running tasks is something that developers/users of Akka.NET need to learn anyway, as the same apply to the synchronous message pipeline.

@rogeralsing
Copy link
Contributor

Closing as this breaks actor concurrency..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants