Production Context
High-throughput .NET backend services relying heavily on ambient context (such as tenant IDs, correlation IDs, or security principals via AsyncLocal<T> ) frequently encounter silent allocation overhead. Every time an asynchronous continuation flows across execution contexts, the runtime historically duplicates internal dictionary nodes using a copy-on-write mechanism. Under massive concurrent loads, this triggers unnecessary Gen0 GC pressure.
.NET 11 addresses this bottleneck by redesigning the underlying runtime execution context flow to achieve zero-allocation context propagation.
Before
private static readonly AsyncLocal < UserContext > _ctx = new ( ) ;
public void ProcessRequest ( UserContext context ) { // Legacy flow allocates tree nodes on context flow _ctx . Value = context ; await Task .…