How Profile-Guided Optimization Makes Your Code Faster Without Any Code Changes
summary
Profile-guided optimization with GCC compiles once with -fprofile-generate, runs representative workloads to produce main.gca, then recompiles with -fprofile-use to change code layout and inlining decisions. Measured with perf counters, hot/cold function splitting and call reordering cut L1 instruction-cache misses from ~6M to ~1.5M and cut a microbenchmark from 0.206s to 0.17s; devirtualization inlines the common virtual case. Chrome reports ~10% faster page loads and Clang shows ~20% faster builds when built with PGO.
AI-written summary · about
chapters (10)
- 0:00Start
- 1:59Problem - Missed Compiler Optimizations
- 3:25Profile Guided Optimization (PGO)
- 4:57How to use PGO
- 6:18Training
- 32:53Virtual Tables
- 41:47Missing profile data
- 44:06Excluding Functions - Attributes
- 44:16Untrainable Functions
- 45:48Sources & Further Material
related talks
01h 01mPlenary: Performance Matters
01h 06m“Improving Performance Through Compiler Switches..."
01h 30mTuning C++: Benchmarks, and CPUs, and Compilers! Oh My!
53mOptimizing C for Microcontrollers - Best Practices
01h 37mAn Overview of Program Optimization Techniques
52mWriting fast C code for a modern CPU (and applying it to PostgreSQL)
49mAn Engineering Approach to Optimising C++
01h 04mDesign for Performance
