Steve Gordon
Turbocharged: Writing High-Performance C# and .NET Code
#1about 2 minutes
Defining performance metrics for .NET applications
Performance is defined by three key metrics: execution time, throughput, and memory allocations, which influence garbage collection frequency.
#2about 1 minute
Adopting a scientific approach to code optimization
Follow a simple, iterative cycle of measuring with data, optimizing a small part of the code, and then measuring again to validate improvements.
#3about 2 minutes
Choosing the right tools for performance measurement
Use tools like Visual Studio diagnostic tools for profiling and Benchmark.NET for precise micro-benchmarking of specific code paths.
#4about 2 minutes
Getting started with Benchmark.NET for micro-benchmarking
Benchmark.NET is an open-source library that provides high-precision measurements for small units of code by handling warm-up and statistical analysis.
#5about 3 minutes
Understanding Span<T> for efficient memory operations
Span<T> provides a type-safe, read/write view over a contiguous region of memory, such as arrays or stack-allocated memory, without new allocations.
#6about 4 minutes
Using Span<T> slicing to optimize array operations
Slicing a span creates a new view over a portion of the original data in constant time, avoiding the overhead of creating new arrays and copying data.
#7about 2 minutes
Parsing strings without allocations using ReadOnlySpan<char>
Create a `ReadOnlySpan<char>` from a string to parse it by slicing, which avoids creating new substring allocations and reduces memory pressure.
#8about 3 minutes
Navigating Span<T> limitations with Memory<T>
Since `Span<T>` is a stack-only `ref struct`, use the `Memory<T>` type in heap-based scenarios like async methods, then get a span from it when needed.
#9about 4 minutes
Case study: Optimizing S3 object key generation
A practical example shows how replacing string arrays and regex with `Span<T>` and stack allocation dramatically reduced memory allocations from 1KB to 192 bytes per operation.
#10about 2 minutes
Reusing temporary buffers with ArrayPool
Use `ArrayPool<T>` to rent and return temporary arrays, which reduces garbage collection pressure by reusing buffers instead of allocating new ones repeatedly.
#11about 2 minutes
Implementing high-performance I/O with System.IO.Pipelines
System.IO.Pipelines simplifies efficient stream processing by managing buffers from an `ArrayPool`, allowing you to work with data as it becomes available.
#12about 4 minutes
Case study: Parsing large files with pipelines
By replacing a library that loaded an entire file into memory with a pipeline-based parser, allocations were reduced from over 7.2 GB to 242 MB.
#13about 2 minutes
Making the business case for performance optimization
Translate performance gains like reduced allocations and increased throughput into monetary value, such as lower infrastructure costs, to get buy-in from stakeholders.
#14about 3 minutes
Summary of key principles for high-performance code
Always measure your code, focus on hot paths, avoid memory copies by using `Span<T>`, and consider `ArrayPool` and `Pipelines` for I/O-heavy scenarios.
#15about 4 minutes
Q&A: Span to array costs and using ValueTasks
The Q&A covers the cost of converting a span back to an array and discusses when to use `ValueTask` over `Task` to avoid allocations in synchronous completion paths.
Related jobs
Jobs that call for the skills explored in this talk.
Matching moments
20:48 MIN
Using micro-benchmarking for performance hotspots
What you can learn from an open-source project with 500 million downloads
04:52 MIN
The critical need for performance in modern applications
In-Memory Computing - The Big Picture
00:35 MIN
Why JVM memory management and structure matter
Trash Talk - Exploring the memory management in the JVM
25:07 MIN
Q&A on performance, interfaces, and advanced learning
Where we're going we don't need JavaScript - Programming with Type Annotations
29:15 MIN
Audience Q&A on JIT compilation and performance
Just-in-time Compilation in JVM
17:25 MIN
Contrasting minimalist code with modernizing legacy applications
The weekly developer show: Boosting Python with CUDA, CSS Updates & Navigating New Tech Stacks
00:04 MIN
Overview of modern C# community-loved features
Modern C#: A Dive into the Community's Most Loved new Features.
13:27 MIN
Why Microsoft is rewriting the TypeScript compiler in Go
WeAreDevelopers LIVE - the weekly developer show with Chris Heilmann and Daniel Cranney
Featured Partners
Related Videos
C# Lowering - What is it and why should I care?
Steven Giesel
Things I learned while writing high-performance JavaScript applications
Michele Riva
5 features that help you get the most out of C# 10
Louëlla Creemers
Tips, tricks and quirks in .NET
Paweł Łukaszuk
WebAssembly: Disassembled
Stefan Schöberl
Modern C#: A Dive into the Community's Most Loved new Features.
Louëlla Creemers
Hacking C# from the inside - how to do anything in NET
Adam Furmanek
Trash Talk - Exploring the memory management in the JVM
Gerrit Grunwald
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.
![Senior Software Engineer [TypeScript] (Prisma Postgres)](https://wearedevelopers.imgix.net/company/283ba9dbbab3649de02b9b49e6284fd9/cover/oKWz2s90Z218LE8pFthP.png?w=400&ar=3.55&fit=crop&crop=entropy&auto=compress,format)
Senior Software Engineer [TypeScript] (Prisma Postgres)
Prisma
Remote
Senior
Node.js
TypeScript
PostgreSQL

Cloud Engineer (m/w/d)
fulfillmenttools
Köln, Germany
€50-65K
Intermediate
TypeScript
Google Cloud Platform
Continuous Integration

DevOps Engineer – Kubernetes & Cloud (m/w/d)
epostbox epb GmbH
Berlin, Germany
Intermediate
Senior
DevOps
Kubernetes
Cloud (AWS/Google/Azure)


Senior Machine Learning Engineer (f/m/d)
MARKT-PILOT GmbH
Stuttgart, Germany
Remote
€75-90K
Senior
Python
Docker
Machine Learning

Staff CPU Performance Benchmarking Engineer
Arm Limited
Cambridge, United Kingdom
ARM
Perl
VHDL
Linux
Python
+2


Performance Tester - Contract
Pixelcode Technologies Limited
Wellesbourne, United Kingdom
€104K
API
JMeter
Performance Testing
Continuous Integration

Senior Software Engineer C# / .net
Jordan Martorell S.L.
Municipality of Madrid, Spain
C++
Java
.NET
Python