Performance
Senior performance is measurement-led. BenchmarkDotNet for microbenchmarks, async pitfalls (sync-over-async, ConfigureAwait, threadpool starvation), proper parallelism for CPU-bound work, allocation hunting, string/buffer perf, and the profiler toolbox.
Topics (canonical order)
-
:material-stopwatch:{ .lg .middle } BenchmarkDotNet
How it actually measures, pitfalls (cold JIT, GC pressure, branch prediction),
[MemoryDiagnoser], baselines -
Sync-over-async,
ConfigureAwait,Task.Runmisuse, threadpool starvation diagnosis -
Parallel.ForEachAsync, PLINQ, partitioners — for CPU-bound work, NOT async I/O -
[MemoryDiagnoser], ETW, dotMemory, common allocation sources -
StringBuilder, interpolation handlers,SearchValues,Utf8Formatter,string.Create -
dotnet-traceto PerfView, sampling vs ETW, identifying hotspots
Why this order
Without BenchmarkDotNet you're guessing, so it leads. Async pitfalls follow because async perf bugs are the #1 production-incident category for .NET seniors. Parallelism comes next because it's frequently confused with async. Allocations and string/buffer perf are the next tier (most apps live here). Profiling tools close the section as the "now what" when a benchmark or a customer reports something.
Cross-references
- Async pitfalls reference Async/Await — SyncContext & Deadlocks and Diagnostics Tools.
- Allocation hunting connects to GC Fundamentals and Memory Allocations & Pooling.
- String/buffer perf builds on Span, Memory & ref structs.