Compilers can be surprising
summary
Claim: modern front-end and JIT back-end compilers are surprisingly fragile and can turn tiny source changes into huge performance swings. Demos use SharpLab, a custom Visual Studio decompiler and WinDbg; examples show reordered multiplies producing a 20× difference, bounds-check removal via loop cloning after copying arrays to locals, span slices required to avoid hidden checks, and a throw helper pattern (void function whose only exit throws) to keep exception setup off the hot path. Reported gains: ~50% from local copies, 2–3× for compound ops, 10–20× for struct virtualization fixes; .NET 6 fixes some but not all.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:34Why compilers surprise us
- 2:58Compiler basics and JIT
- 8:18JIT compilation steps
- 12:32Breaking compilers with demos
- 13:34Assembly code primer
- 14:36Multiplication order demo
- 17:44If statement surprises
- 23:25Throw helper optimization
- 26:56Switch case optimizations
- 32:12Loop performance traps
- 39:38Precomputation and hoisting
- 41:42Span optimizations
- 44:11Struct and interface quirks
- 52:15Performance gains summary
- 53:40Does .NET 6 fix it all?
- 55:05Q&A
related talks
34mWhat happens to your code when you don't look?
01h 16m“What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”
15mNot So Fast: Understanding and Mitigating Negative Impacts of Compiler Optimizations on Code Reuse G
01h 04mCompiler Bugs And Bug Compilers
46mCompilers, User Interfaces & the Rest of Us
53mLocknote: How Badly Do We Want Correct Compilers?
54mWhat Lies Beneath
09mCompilers for nothing, executables for free!
