Lesson's Learned Optimizing Performance of Go Code
summary
Polar Signals runs weekly live optimizations against Kubernetes, Prometheus, Cilium and containerd using an always-on profiler built on eBPF and the open source parca project, plus Go benchmarks and escape analysis. A concrete fix replaces reading an entire file with a 64-byte stack buffer, removing an allocation and cutting that function’s latency ~17% and shaving ~4% off containerd’s CPU (the function was ~20% of process CPU). Systematic use of buffer reuse, sync.Pool, PGO and SIMD yields routine 25–50% CPU reductions.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:12Moore's Law implications
- 5:11Three rules for performance
- 7:16Why continuous profiling
- 10:48Parca architecture
- 12:34Parca demo
- 14:02Memory reporting in containerd
- 16:31Writing benchmarks
- 19:46Avoiding memory allocations
- 24:25Stack vs heap
- 25:30Fixing escape analysis
- 30:34Benchmarking optimized code
- 31:58Batch operations and reuse
- 34:31Compiler optimizations
- 37:46Profile guided optimizations
- 39:14SIMD and CPU instructions
- 41:01Beating Moore's Law
related talks
44mGo Profiling and Observability from Scratch
51mObscure Go Optimisations
45mBoost application performance with profile guided optimization
14mOptimizing Go code without a blindfold
29mOptimizing Go Code Without a Blindfold
33mBuilding a Go Profiler Using Go
34mGolang: Specific Performance Issues
50mMADPIG: Measure and deepen performance in Go
