Skip to content

Emit TaskWaitBegin for RuntimeAsync suspensions - #133028

Open
tommcdon wants to merge 1 commit into
dotnet:mainfrom
tommcdon:dev/tommcdon/runtimeasync-crossprocess-taskwaitbegin-minimal
Open

Emit TaskWaitBegin for RuntimeAsync suspensions#133028
tommcdon wants to merge 1 commit into
dotnet:mainfrom
tommcdon:dev/tommcdon/runtimeasync-crossprocess-taskwaitbegin-minimal

Conversation

@tommcdon

@tommcdon tommcdon commented Sep 1, 2026

Copy link
Copy Markdown
Member

Expose the existing awaited-task relationship to debugger ETW consumers without walking or enumerating Task objects.

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>
@tommcdon
tommcdon requested review from lateralusX and rcj1 September 1, 2026 17:20
@tommcdon tommcdon self-assigned this Sep 1, 2026
Copilot AI lite review requested due to automatic review settings September 1, 2026 17:20
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 Task from the next continuation when it’s a RuntimeAsyncTaskContinuation.
  • Emits TplEventSource.Log.TaskWaitBegin(...) during InstrumentedHandleSuspended when 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);
}
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