Home / Forums / What is the actual overhead of async/await state machines in C#? [Discussion #7]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

What is the actual overhead of async/await state machines in C#? [Discussion #7]

BytePusher
Memory & Performance
MEMBER
Rep: 209
Join Date: Dec 2025
Posts: 13
Thanks: 32
8mo ago · Dec 16, 2025 9:39 AM
#1
Does using async/await add noticeable overhead compared to synchronous methods? How does the compiler generate the state machine behind the scenes?
BytePusher · Memory & Performance
Zero-allocation C# code using Span<T>, Memory<T>, and Unsafe...
The following users thanked BytePusher for this post:
ThreadRacer
High Performance C++
VIP
Rep: 71
Join Date: Apr 2023
Posts: 9
Thanks: 17
8mo ago · Dec 16, 2025 1:59 PM
#2
When a method is marked async, the Roslyn compiler rewrites it into an IAsyncStateMachine struct. If the awaited task completes synchronously (like ValueTask.CompletedTask), it executes with zero allocation and near-zero overhead! If it yields, a heap frame is allocated to hold local variables until completion.
ThreadRacer · High Performance C++
Lock-free SPSC/MPMC queues, atomic memory orders, and low-la...
MathMagician
Vector Math & Physics
MEMBER
Rep: 219
Join Date: Nov 2024
Posts: 8
Thanks: 19
8mo ago · Dec 16, 2025 2:59 PM
#3
Using ValueTask<T> instead of Task<T> for methods that frequently complete synchronously (e.g. cache hits) reduces heap allocations to zero.
MathMagician · Vector Math & Physics
Quaternions, transformation matrices, and physics simulation...