Reclaiming CPU for free with Go's Profile Guided Optimization
Golang 1.20 introduced Profile Guided Optimization (PGO), which allows guiding the compiler to introduce optimizations based on real-world behavior of a system. PGO can lead to CPU usage reductions, freeing up resources for better customer service. The process involves compiling a non-PGO binary and deploying it to production, collecting CPU profiles from the binary in production, and then compiling a second binary using that CPU profile. An example is provided where PGO was used on Cloudflare's "wshim" system, leading to significant CPU usage reductions. Future work includes automating profile collection, refining deployment processes, and implementing further improvements with other optimization techniques.
Company
Cloudflare
Date published
May 14, 2024
Author(s)
Colin Douch
Word count
1278
Hacker News points
None found.
Language
English