High Performance JSON Serialization With Code Generation on C# 11 and .NET 7.0
summary
Compares Newtonsoft.Json to System.Text.Json on .NET 7 and C# 11, showing UTF‑8 native parsing avoids the UTF‑16 conversion cost and slashes memory from ~22 MB to ~4–5 MB for 10,000 objects; using JsonElement yields ~222 bytes total allocation and ~4 ms to find the 5,000th item, while a streaming Utf8JsonReader implementation drops allocations to ~50 bytes. Demonstrates source generators (Corvus.JsonSchema and SDK generators) that remove reflection cold‑start costs and emit fast serializers that work and scale.
AI-written summary · about
chapters (12)
- 0:00Introduction to JSON perf
- 1:48Problems with Newtonsoft JSON
- 8:06Newtonsoft JSON benchmarking
- 20:24System.Text.JSON overview
- 28:54System.Text.JSON benchmarks
- 33:21JSON element API performance
- 40:44Deep dive into JSON element
- 48:17Reflection vs code generation
- 55:10Source generators in .NET
- 1:02:53Advanced generation techniques
- 1:11:06Conclusion and Q&A
- 1:15:01Environmental impact discussion
related talks
01h 01mTurbocharged: Writing High-Performance C# and .NET Code
01h 14mTurbocharged: Writing High-performance C# and .NET code
01h 04mTurbocharged: Writing High-Performance C# and .NET Code
54mExploring Source Generators
01h 09mPatterns for high-performance C#
56mState of the .NET Performance
52mPerformance features in C#
37mRock Your Code Code and App Performance for Microsoft .Net
