Cloudflare is touting Go’s Profile Guided Optimization (PGO), saying it saved the company significant CPU usage without changing any code.
PGO allows the Go compiler to optimize code based on system’s real-world behavior, essentially providing customized performance profiles. The feature is described as providing anywhere from a 2% to 14% performance improvement.
Cloudflare says an improvement of just a few points would result in significant benefit to the company and its customers.
In the Observability Team at Cloudflare, we maintain a few Go-based services that use thousands of cores worldwide, so even the 2-7% savings advertised would drastically reduce our CPU footprint, effectively for free. his would reduce the CPU usage for our internal services, freeing up those resources to serve customer requests, providing measurable improvements to our customer experience.
After experimenting with PGO on its Go-based servers, the company saw the results it was hoping for.
Following the release, we’re using ~97 cores fewer than before the release, a ~3.5% reduction. This seems to be inline with the upstream documentation that gives numbers between 2% and 14%.
The second number we can look at is the usage at the same time of day on different days of the week. The average usage for the 7 days prior to the release was 3067.83 cores, whereas the 7 days after the release were 2996.78, a savings of 71 CPUs. Not quite as good as our 97 CPU savings, but still pretty substantial!
This seems to prove the benefits of PGO – without changing the code at all, we managed to save ourselves several servers worth of CPU time.
Cloudflare’s results are a major endorsement of the value of PGO support in Go.