-
Notifications
You must be signed in to change notification settings - Fork 789
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
Bind of Async<> within task{} should start on the same thread #14499
Bind of Async<> within task{} should start on the same thread #14499
Conversation
…artastask-which-involves-a-context-switch
Please, bump |
…artastask-which-involves-a-context-switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be completely fair, I'm still unsure if it was not a desired behaviour (starting on a thread pool).
@dsyme was it a deliberate choice?
For full completeness and why I believe this should be treated like a bug/inconsistency: async inside Task: Outer task before: 1, inner async: 8, after inner async: 8, outside of the CE: 1 Code:
|
@T-Gro that’s an excellent summary. I agree, this looks like a minor oversight and should be fixed, ideally in a point release (I assume we won’t publish fixes on the 6.0.x branch anymore, right? This’ll be just 7.0.x? As that’d be an even greater reason in my book to not wait until 8.x). Do note that similar wrong behaviour exists for running an async computation and hopping to a different thread immediately (as opposed to when nested), see original issue for details. |
The automatic versioning will cover for this with next product release.
…artastask-which-involves-a-context-switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, since it's an implementation detail change - not really explicitly breaking.
I'm just wondering what's what the thinking behind having current behaviour in the first place. Will discuss with Don in NY.
To answer my own question, and for posterity, this fix will only live in the F# Core 7.x.x versions published after today, there will not be a new 6.0.x (afaik). |
Sorry for the radio silence -> yes, this is the plan. I do not see this as a 'showstopper' kind of bug that should be backported, even though we technically can if this causes enough pain. |
I agree with the fix :) Nice job |
This addresses #14490 .
I am now of the opinion of the current behavior being a bug, and this change should be treated like a bugfix.
None of the docs for task{} and async{} mention starting work on a new thread, this operation is considered to be done explicitly by user code instead.
The proposed change for 'async{} inside task{}' is also consistent with 'async in async' situation, causing less surprises when moving between task{} and async{}.
When it comes to backwards compatibility issues, GUI/main thread involvement is one thing to have in mind.
In the actual behavior's, the code could start on main thread, do the inner async{} elsewhere, and then return.
The proposed change will keep the same context, which I again see as a bugfix - both for correctness sake, but especially for resource utilization.