.NET is evolving at a rapid pace, making strides into new platforms and environments, and getting new features and enhancements from the community. At the same time, writing fast .NET applications requires significant understanding of the underlying platform and the new features the .NET framework has to offer. This workshop introduces a set of practical techniques, tools, and libraries for improving .NET application performance on the code level. We will discuss modern processor organization and SIMD instructions, and leverage them with the System.Numerics.Vectors library and the new RyuJIT 64-bit compiler. We will explore garbage collector internals, including the most recent changes, and how to identify and tackle common GC performance issues. We will see where unsafe code can still make sense, and how to measure and improve application startup performance. Throughout the day, you will work on hands-on labs that reinforce the material and leave you with practical examples of how to apply these optimizations to your own products.
Tentative outline:
- The modern .NET platform landscape (Windows, Linux, .NET Core vs. Desktop, GC, JIT, AOT compilation)
- Processor organization: frontend/backend, execution units, pipeline stalls, memory access, cache hierarchy
- PMU events in modern processors: cache misses, stalls, TLB misses, instructions retired, branch prediction
- LAB: Measuring processor performance with BenchmarkDotNet and ETW
- SIMD instructions, latency, throughput
- System.Numerics.Vectors and RyuJIT 64-bit support, Vector<T>, operations on vectors
- LAB: Vectorizing linear algorithms
- LAB: Vectorizing algorithms with inter-dependencies
- .NET garbage collection survey: mark/sweep/compact, roots, generations, server/workstation GC, background/foreground GC, SOH/LOH, finalization
- Monitoring garbage collection performance with performance counters and ETW
- Monitoring allocation behavior: allocation sampling, thorough allocation profiling
- LAB: GC monitoring and allocation profiling
- Best practices for improving GC behavior: value types, allocations, generations, finalization
- Unsafe code: Marshal, pointers, the ‘fixed’ statement, stackalloc, Span<T>
- Startup performance: cold/warm startup, disk accesses, JIT compilation, AOT compilation (NGen/Crossgen)
- LAB: Measuring and identifying factors in application startup performance
During this full-day workshop, you will have the opportunity to perform hands-on exercises.
To be able to follow those exercises, you will need your laptop with the following software installed:
Windows 7 or later
Visual Studio 2017 installed