Skip to content

JIT: optimize always-suspending helpers #128324

Closed

Description

@jakobbotsch

There are several frequently used async helpers that always suspend. We can optimize these specially to skip checking for a null continuation after they return.

  • UnsafeAwaitAwaiter
  • AwaitAwaiter
  • TransparentAwait
  • TransparentAwaitOfT
  • TransparentAwaitValueTask
  • TransparentAwaitValueTaskOfT

Concretely my plan of attack would be something like:

  • Make sure the above functions are marked as [Intrinsic] and start recognizing them in lookupNamedIntrinsic
  • Add a bool AlwaysSuspends field to AsyncCallInfo and assign it in impSetupAsyncCall for these intrinsics
  • Teach AsyncTransformation::CreateCheckAndSuspendAfterCall to skip the check for this AlwaysSuspends case

When implemented, we should see a codegen improvement in a case like

async Task Foo()
{
  await Task.Yield();
}

with runtime-async enabled (add the following to the .csproj:

    <Features>$(Features);runtime-async=on</Features>

)

Activity

  1. added
    untriaged
    on May 18, 2026
  2. added and removed
    untriaged
    on May 18, 2026
  3. dotnet-policy-service commented on May 18, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @VSadov
    See info in area-owners.md if you want to be subscribed.

  4. added
    area-CodeGen-coreclr
    and removed on May 18, 2026
  5. dotnet-policy-service commented on May 18, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  6. added
    help wanted
    and removed
    help wanted
    on May 18, 2026
  7. added this to the 11.0.0 milestone on May 18, 2026
  8. added
    Priority:3
    on Jul 9, 2026
  9. locked and limited conversation to collaborators on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Priority:3area-CodeGen-coreclrruntime-async

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions