Check the IValueTaskSource case first in HandleSuspended - #133076
Conversation
The introducers of asynchrony in RuntimeAsyncStackState are mutually exclusive, so the order of the checks in RuntimeAsyncTask<T>.HandleSuspended only affects how quickly each kind of suspension is dispatched. High-performance sources of asynchrony are increasingly expected to be IValueTaskSource based rather than ICriticalNotifyCompletion based, so test the ValueTaskSourceContinuation case first and let the awaiter/notifier cases fall through behind it. No behavioral change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 2146252b-ee64-4e0f-8aac-b9baa38e1a7a
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke |
There was a problem hiding this comment.
🟢 Approval recommended
The change is a straightforward reordering of mutually-exclusive dispatch cases with no functional logic changes and no issues found in surrounding invariants.
Pull request overview
Reorders the suspension-dispatch checks in RuntimeAsyncTask<T>.HandleSuspended to prioritize the IValueTaskSource-backed continuation path (ValueTaskSourceContinuation) before the awaiter/notifier/task continuation paths, aiming to reduce dispatch latency for that case without changing semantics.
Changes:
- Checks
ValueTaskSourceContinuationfirst inHandleSuspended, moving the other continuation cases after it. - Keeps the existing dispatch behavior for awaiter, critical notifier, and task continuation cases unchanged aside from evaluation order.
File summaries
| File | Description |
|---|---|
| src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | Reorders HandleSuspended’s mutually-exclusive suspension-kind checks to prioritize the IValueTaskSource continuation path. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
|
PTAL @VSadov. Simple change to reorder the checks to put |
VSadov
left a comment
There was a problem hiding this comment.
This is just a reorder of mutually exclusive checks with more likely one to be first.
I am not sure this will be easily observable in the overall scenario, but it makes sense.
The introducers of asynchrony in RuntimeAsyncStackState are mutually exclusive, so the order of the checks in RuntimeAsyncTask<T>.HandleSuspended only affects how quickly each kind of suspension is dispatched. High-performance sources of asynchrony are increasingly expected to be IValueTaskSource based rather than ICriticalNotifyCompletion based, so test the ValueTaskSourceContinuation case first and let the awaiter/notifier cases fall through behind it. No behavioral change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The introducers of asynchrony in RuntimeAsyncStackState are mutually exclusive, so the order of the checks in
RuntimeAsyncTask.HandleSuspended only affects how quickly each kind of suspension is dispatched. High-performance sources of asynchrony are increasingly expected to be IValueTaskSource based rather than ICriticalNotifyCompletion based, so test the ValueTaskSourceContinuation case first and let the awaiter/notifier cases fall through behind it.
No behavioral change.