go-performance
Installation
SKILL.md
Go Performance
Start with measurement, not rewriting.
Read the right reference
- Read references/measurement.md for benchmark setup,
go testflags,pprof, trace, flight recording, runtime metrics, and PGO workflow. - Read references/optimization.md when you are changing code after measurement or reviewing hot-path code.
Default workflow
- Reproduce the problem and name the metric that matters:
ns/op,B/op,allocs/op, throughput, tail latency, pause time, goroutine growth, or CPU saturation. - Add or repair a benchmark before changing code. On Go 1.24+ prefer
b.Loop()for new or edited benchmarks unless the repo must support older Go. - Run the benchmark repeatedly and compare with
benchstat; do not trust one run. - Collect one diagnostic at a time: CPU, heap/allocs, mutex, block, or trace. Do not mix profiles unless you must; diagnostics can distort each other.
- Fix the dominant cost first: algorithmic complexity, redundant work, bad data layout, excess allocation, or contention.
- Re-run the same benchmark and compare with
benchstat. - Apply PGO only after the code path is correct and the profile is representative.
- Validate the change under realistic service conditions with runtime metrics,
net/http/pprof, or flight recording if the issue is production-only.