Boost application performance with profile guided optimization
summary
Go 1.21 adds profile guided optimization so the compiler uses real runtime profiles (place as default.pggo beside package main or pass -pggo) to guide inlining and escape analysis, often moving heap allocations to the stack. Using net/http/pprof and go tool pprof or a continuous profiler yields production profiles; typical wins are ~10% CPU and latency improvement (best ~15%, sometimes as low as 2%), reduced Cloud Run billable time, and stable iterative builds that tolerate source drift. peepoff and pprof packages help analyze changes.
AI-written summary · about
chapters (15)
- 0:00Profile guided optimization intro
- 1:06Compiler optimizations
- 3:52Why separate functions
- 6:40How inlining improves performance
- 9:30Go heap vs stack
- 14:26Compiler heuristic limits
- 16:54PGO runtime profiles
- 19:23Collecting production profiles
- 22:53Building with PGO in Go
- 25:46Measuring PGO impact
- 27:31Deploying to Cloud Run
- 30:45PGO best practices
- 34:16Iterative PGO lifecycle
- 36:24Summary and call to action
- 38:50Q&A
related talks
33mBuilding a Go Profiler Using Go
44mGo Profiling and Observability from Scratch
40mProfiling real-world golang service
40mTwo Go programs, three different profiling techniques, all in 40 minutes
29mOptimizing Go Code Without a Blindfold
34mGolang: Specific Performance Issues
50mMADPIG: Measure and deepen performance in Go
42mLesson's Learned Optimizing Performance of Go Code
