Preserve the V1 async-profiler stitch boundary - #132158
Merged
Merged
Conversation
Keep MoveNextAsDispatcher as a physical frame and strengthen its contract and stack-capture diagnostics. Co-authored-by: Copilot App <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: @dotnet/area-system-threading-tasks |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reinforces the async-profiler V1 “stitch boundary” contract by ensuring AsyncProfilerAsyncStateMachineBox<TStateMachine>.MoveNextAsDispatcher remains a physical (non-inlined) stack frame, and by tightening tests to validate both the naming and non-inlining requirements while improving failure diagnostics.
Changes:
- Mark
AsyncProfilerAsyncStateMachineBox<TStateMachine>.MoveNextAsDispatcherasMethodImplOptions.NoInliningto preserve the physical stitch boundary frame. - Extend the V1 method-name contract test to also require
MethodImplAttributes.NoInliningforV1.MoveNextAsDispatcher. - Improve test diagnostics by capturing and printing full per-frame
DeclaringType::Methodinformation (with explicit<unknown-*>markers) when stack-based assertions fail.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerV2Tests.cs | Update resume-dispatch capture plumbing to carry diagnostic frame strings into boundary assertions. |
| src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerV1Tests.cs | Extend V1 boundary tests to pass diagnostic frames through and enforce NoInlining for MoveNextAsDispatcher; improve assertion failure messages. |
| src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs | Enhance shared helpers to capture diagnostic frame names and thread them into assertion helpers; expose MethodInfo for contract checks. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs | Add MethodImplOptions.NoInlining to MoveNextAsDispatcher to preserve the V1 physical stitch boundary frame. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
noahfalk
approved these changes
Aug 11, 2026
steveisok
enabled auto-merge (squash)
August 12, 2026 16:31
Member
Author
|
/ba-g Helix monitor job failed |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
AsyncProfilerAsyncStateMachineBox<TStateMachine>.MoveNextAsDispatcherasNoInliningso the V1 stitch boundary remains a physical frame.MethodImplAttributes.NoInliningfor that boundary.DiagnosticMethodInfodeclaring type and method name in physical-stack assertion failures, with explicit unknown markers.Debugger evidence
A checked CoreCLR debugger probe showed that Debug and Release both:
AsyncProfilerAsyncStateMachineBox<TStateMachine>;_isLeafbefore resume;MoveNextAsDispatcher; andDiagnosticMethodInfowhen it is physically present.The compiler lowering differs as expected: the Debug state machine is a class, while the Release state machine is a struct. This rules out an alternate Debug dispatch path, listener activation, box selection, and frame classification as the intended difference. The missing CI frame therefore exposes an unenforced physical-frame contract.
The CI-specific omission was not reproduced locally, including with Debug libraries, checked CoreCLR, CI build properties, tiering disabled, ReadyToRun disabled, and JIT minopts. Normal PR CI should validate the affected Debug/checked legs.
Validation
./build.sh clr.corelib+clr.nativecorelib+libs.pretest -rc checked -lc debugV1AsyncDispatchMethod_NameContract_IsStable: 2 passedStateMachineAsync_ResumeDispatchStack: 1 passedStateMachineAsync_InlineCompletionClimb: 1 passedFixes #132025
Fixes #132026
Note
This PR description was generated with GitHub Copilot.