.NET 5 is the fastest .NET version ever releases. The engineering team has gone through the runtime and libraries with a fine-toothed comb, optimizing everything from the impacts of the Garbage Collector (GC) to the internals of List<T>. Let’s look at the numbers.
TechEmpower Benchmarks
In the TechEmpower benchmarks (Round 19/20), .NET 5 performs exceptionally well, often ranking in the top tier against C++, Rust, and Go frameworks, and significantly outpacing Java and Node.js.
gantt
title Requests Per Second (Thousands) - JSON Serialization
dateFormat X
axisFormat %s
section Frameworks
.NET 5 (ASP.NET Core) : 1050, 0, 1050
.NET Core 3.1 : 750, 0, 750
Node.js (Fastify) : 350, 0, 350
Java (Spring Boot) : 250, 0, 250
PGO (Profile-Guided Optimization)
The JIT compiler now makes smarter decisions about code layout and register allocation. PGO improvements mean that common code paths are optimized more aggressively.
System.Text.Json Improvements
JSON performance is critical for microservices. .NET 5 improves System.Text.Json significantly:
// HttpClient now has extension methods for JSON
// No more stream copying to memory first
var widgets = await client.GetFromJsonAsync<List<Widget>>("/widgets");
Small object deserialization is ~20% faster, and large collections handled with JsonSerializer are up to 30% faster than 3.1.
Regular Expressions
Regex performance has improved by an order of magnitude in some cases. The engine now emits better IL and uses vectorization (SIMD) instructions where possible.
Garbage Collection
The GC sees improvements in reducing pause times. “Card marking” logic was optimized, and pinned object handling (often used in I/O) is much more efficient, reducing fragmentation.
Key Takeaways
- Upgrade to .NET 5 often yields “free” performance gains of 10-30% without code changes.
- gRPC performance in .NET 5 is best-in-class.
- Socket handling on Linux has been rewritten (epoll) for better scalability.
References
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.