Emit TaskWaitBegin for RuntimeAsync suspensions - #133028
Open
tommcdon wants to merge 1 commit into
Open
Conversation
Expose the existing awaited-task relationship to debugger ETW consumers without walking or enumerating Task objects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates CoreCLR’s RuntimeAsync suspension instrumentation to emit a TplEventSource.TaskWaitBegin ETW event that links the suspended RuntimeAsync “current task” to the awaited Task, enabling debugger-oriented ETW consumers to observe the await relationship without enumerating Task objects.
Changes:
- Extracts the awaited
Taskfrom the next continuation when it’s aRuntimeAsyncTaskContinuation. - Emits
TplEventSource.Log.TaskWaitBegin(...)duringInstrumentedHandleSuspendedwhen async-debugger instrumentation is enabled.
File summaries
| File | Description |
|---|---|
| src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | Emits TaskWaitBegin on RuntimeAsync suspension by using the awaited Task from RuntimeAsyncTaskContinuation. |
Review details
Suppressed comments (1)
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs:916
- This adds a TaskWaitBegin event for a RuntimeAsync suspension but doesn’t emit a corresponding TaskWaitEnd / TaskWaitContinuationComplete when the awaited Task completes and the continuation runs. That will leave unmatched TaskWaitBegin events in traces (unlike the await path in TaskAwaiter.OutputWaitEtwEvents, which pairs begin/end), which can break ETW timeline visualizations and duration calculations.
TplEventSource.Log.TaskWaitBegin(
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Comment on lines
+914
to
+922
| if (awaitedTask is not null) | ||
| { | ||
| TplEventSource.Log.TaskWaitBegin( | ||
| m_taskScheduler?.Id ?? TaskScheduler.Default.Id, | ||
| Id, | ||
| awaitedTask.Id, | ||
| TplEventSource.TaskWaitBehavior.Asynchronous, | ||
| Id); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose the existing awaited-task relationship to debugger ETW consumers without walking or enumerating Task objects.