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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

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

Algorithmic
Math & Algorithms
MEMBER
Rep: 45
Join Date: Jan 2020
Posts: 6
Thanks: 55
8mo ago · Dec 7, 2025 4:03 PM
#1
Does using async/await add noticeable overhead compared to synchronous methods? How does the compiler generate the state machine behind the scenes?
Algorithmic · Math & Algorithms
Linear algebra, pathfinding, binary spatial partitioning, an...
The following users thanked Algorithmic for this post:
ShaderGuru
HLSL & GLSL Shader Dev
MEMBER
Rep: 219
Join Date: May 2024
Posts: 6
Thanks: 62
8mo ago · Dec 7, 2025 7:29 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.
ShaderGuru · HLSL & GLSL Shader Dev
Post-processing shaders, stencil buffer tricks, and screen-s...
ImGuiArtist
Modern UI Designer
MEMBER
Rep: 227
Join Date: Dec 2025
Posts: 6
Thanks: 63
8mo ago · Dec 8, 2025 1:29 AM
#3
Using ValueTask<T> instead of Task<T> for methods that frequently complete synchronously (e.g. cache hits) reduces heap allocations to zero.
ImGuiArtist · Modern UI Designer
Dark glassmorphism, animated sliders, and custom font render...