Opt pooled async methods out of runtime async#128943
Draft
jakobbotsch wants to merge 4 commits into
Draft
Conversation
We do not have a replacement for this concept in runtime async (yet). For now opt these methods out of runtime async.
Contributor
|
Tagging subscribers to this area: @dotnet/area-meta |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an internal opt-out mechanism for “runtime async” generation and applies it to a set of pooled-async (PoolingAsyncValueTaskMethodBuilder*) methods across core libraries and key networking/IO components to avoid regressions when runtime async is enabled.
Changes:
- Add
RuntimeAsyncMethodGenerationAttribute(internal, shared source) to control runtime-async method generation. - Annotate selected pooled-async methods with
[RuntimeAsyncMethodGeneration(false)]in core IO, pipelines, and System.Net implementations. - Wire the shared attribute source into multiple library projects so the annotation is available at compile time.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs | Opts ReadAtLeastAsyncCore (pooled async) out of runtime async generation. |
| src/libraries/System.Private.CoreLib/src/System/IO/Strategies/BufferedFileStreamStrategy.cs | Opts ReadAsyncSlowPath / WriteAsyncSlowPath pooled async paths out of runtime async generation. |
| src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems | Includes the new shared attribute source in CoreLib (link path needs adjustment). |
| src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs | Opts key pooled async receive/buffering helpers out of runtime async generation. |
| src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj | Includes the shared attribute source file in the project. |
| src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs | Opts pooled async TLS frame/read helpers out of runtime async generation. |
| src/libraries/System.Net.Security/src/System.Net.Security.csproj | Includes the shared attribute source file in the project. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs | Opts pooled async ReadAsync override out of runtime async generation. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs | Opts pooled async ReadBufferedAsyncCore out of runtime async generation. |
| src/libraries/System.Net.Http/src/System.Net.Http.csproj | Includes the shared attribute source file in the project. |
| src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj | Includes the shared attribute source file in the project. |
| src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeWriter.cs | Opts pooled async flush core out of runtime async generation (NET-only section). |
| src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeReader.cs | Opts pooled async local core reader loop out of runtime async generation (NET-only section). |
| src/libraries/System.IO.Pipelines/src/System.IO.Pipelines.csproj | Includes the shared attribute source file for .NETCoreApp builds. |
| src/libraries/Common/src/System/Threading/AsyncOverSyncWithIoCancellation.cs | Opts pooled async work-item wrappers out of runtime async generation. |
| src/libraries/Common/src/System/Runtime/CompilerServices/RuntimeAsyncMethodGenerationAttribute.cs | Adds the shared internal attribute definition (minor implementation/style issues noted). |
Comment on lines
+2318
to
+2320
| <Compile Include="$(CommonPath)System\Runtime\CompilerServices\RuntimeAsyncMethodGenerationAttribute.cs"> | ||
| <Link>Common\Runtime\CompilerServices\RuntimeAsyncMethodGenerationAttribute.cs</Link> | ||
| </Compile> |
Comment on lines
+6
to
+10
| [AttributeUsage(AttributeTargets.Method)] | ||
| internal sealed class RuntimeAsyncMethodGenerationAttribute(bool runtimeAsync) : Attribute | ||
| { | ||
| public bool RuntimeAsync => runtimeAsync; | ||
| } |
Contributor
|
I would expect that a custom async method builder would imply opting out of runtime async by itself. |
This was referenced Jun 3, 2026
Open
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.
We do not have a replacement for this concept in runtime async (yet) and ASP.NET is seeing some regression from that. For now opt these methods out of runtime async.
cc @BrennanConroy