Runtime

New in .NET 11: Faster ASP.NET Core APIs with runtime async

elmah.io Blog Ali Hamza Ansari
Runtime

With .NET 11, async and await suspension moves from compiler-generated state machines into the runtime. Running the same console app on .NET 10 and .NET 11 shows cleaner live stack traces, fewer allocations and better JIT handling, with no C# changes.

Key points

  • `runtime-async=on` goes into the csproj `Features` property; the C# code itself is untouched.
  • Live stack traces lose internal frames such as `AsyncMethodBuilderCore.Start<TStateMachine>`.
  • Exception traces already showed the async chain; the gain is in live traces from `new StackTrace()`.
  • The JIT adds tail-merged suspension points, tiered async compilation and fast paths for `Task.FromResult`, `Task.CompletedTask` and `ValueTask.FromResult`.
  • ExecutionContext capture is skipped when a continuation has no ambient state to restore, for Task, Task<T>, ValueTask and ValueTask<T>.
  • NativeAOT and ReadyToRun are supported, and crossgen2 may now inline runtime-async methods; breakpoints bind inside them and stepping skips the old plumbing.

Why it matters

Runtime async is the rare change you adopt without rewriting code: add the flag to the csproj and eligible async methods switch execution model, while third-party libraries keep their current shape until they are built against the new toolchain. Because .NET 11 is an STS release, long-lived services may only pick it up on their next LTS move. Even so, it is worth testing early on an async-heavy endpoint for the stack-trace and debugger gains alone. Before production, smoke-test profilers, APM agents and NativeAOT publishing, and treat the article's timings as illustrative rather than a benchmark.

Real-world use

  • A high-throughput API endpoint that runs thousands of small awaits per request.
  • A sequential worker loop that queries PostgreSQL, calls an external HTTP API or reads Azure storage for every item.
  • Profiling and diagnostic logging, where state-machine frames hide the real call chain.
  • NativeAOT or ReadyToRun services that need the same async behaviour without the JIT.

This summary was generated by the agent from the original post on elmah.io Blog. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message