Session
The Allocation Is the Problem
Your code is fast. The garbage collector is not, and it is running because of you.
This is a talk about the layer below algorithmic complexity, for people who have already fixed the obvious things and are still not fast enough. We are going to look at where allocations come from in .NET, which ones matter, and how to get rid of them without making the code unreadable.
Span and Memory, and what they actually buy you beyond looking modern. Stack allocation and when it is safe. String handling, which is where most hot path garbage is born, usually in a line of code that looks completely innocent. Struct enumerators and the closure capture that silently undoes your work. ArrayPool for the cases where you cannot avoid the buffer. And hardware intrinsics, which sound intimidating and are mostly just SIMD with a long type name.
We will look at real benchmarks and real disassembly. Some of the wins are dramatic. Some of them are 3% and I will tell you when 3% is worth it and when you are wasting your life.
There is a cost to all of this and I will be honest about it. Every technique here trades readability for speed. Most of your code should not use any of them. Knowing which code should is the actual skill.
Chris Houdeshell
VP of Eng. and Ops | Bit Herder | ☕
State College, Pennsylvania, United States
Links
Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.
Jump to top