What C and C++ can do and when do you need Assembly?
summary
Shows generated code from GCC and Clang using Compiler Explorer and llvm-mca and compares actual x86-64 microops, latencies and timelines; replacing large switch-based HTTP state machines with goto labels yields 2x speedup on a 900-state parser by cutting branch misses and cache pressure; Spectre and page-table mitigations impose about 15%–30% cost; SLP/vectorization rarely helps the HTTP parser so math/crypto stays in hand-written assembly for multi-limb big-int speedups; user-space spinlocks can cause ~100 ms wake latencies.
AI-written summary · about
chapters (15)
- 0:00Start
- 1:01What C and C++ can do and when do you need Assembly
- 9:35(x86-64) Code execution
- 11:45Intelpocalypse: performance cost
- 12:14Code review: "is the compiler smart enough?"
- 15:02GCC switch optimization: lookup table
- 15:53GCC switch optimization: binary search
- 17:35Direct jumps vs switch: performance
- 19:12GCC labeled code reordering
- 20:46Compiler barrier
- 25:12SIMD optimizations
- 26:18SIMD in the Linux kernel
- 39:45Mixing AVX code with SSE code
- 41:11Easy assembly
- 42:24Spinlocks & huge tail latencies
related talks
01h 00mJust Enough Assembly for Compiler Explorer
01h 30mTuning C++: Benchmarks, and CPUs, and Compilers! Oh My!
01h 00mBeating Hand Tuned Assembly in Compiled Languages
01h 16m“What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”
31m“Enough x86 Assembly to Be Dangerous”
54mx86 Internals for Fun & Profit
01h 06m“Improving Performance Through Compiler Switches..."
01h 21mCPU optimized data structures - more fun with assembler
