← All notes

Profile-guided optimization (PGO) in Go

Answer: Put a pprof CPU profile named default.pgo in the main package directory and go build uses it automatically.

Versions

Steps

  1. Collect a CPU profile from production using runtime/pprof or net/http/pprof.
  2. The standard approach to building is to store a pprof CPU profile with filename default.pgo in the main package directory of the profiled binary. (S1)
  3. Build normally; -pgo=auto is the default.

Notes

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors (go.dev), Profile-guided optimization - The Go Programming Language, CC BY 4.0 (go.dev text); The Go Authors (go.dev), Profile-guided optimization in Go 1.21 - The Go Programming Language, CC BY 4.0 (go.dev text).

Cite this

Permanent ID: iil:note:q4pqb1nw

iinventedlight. 2026. "Profile-guided optimization (PGO) in Go." iinventedlight Library, iil:note:q4pqb1nw, version of 2026-11-04. https://iinventedlight.com/library/notes/go-profile-guided-optimization/. License: CC-BY-4.0.

@misc{iil_note_q4pqb1nw,
  author = {{iinventedlight}},
  title = {{Profile-guided optimization (PGO) in Go}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/go-profile-guided-optimization/},
  note = {Permanent ID iil:note:q4pqb1nw. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/go-profile-guided-optimization.md.