go-performance

Solid

Use when profiling, benchmarking, or optimizing Go code — includes the measure-first methodology, the pprof-driven decision tree (which symptom maps to which fix), allocation reduction, capacity hints, hot-path patterns (strconv vs fmt, repeated string→byte conversions, strings.Builder), and runtime tuning. Apply proactively whenever a user mentions slowness, allocations, GC pressure, or asks for benchmarks, even if no specific pattern is named.

API & Backend 8 stars 1 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
32
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Go Performance Performance work in Go follows one rule: **measure first**. Intuition about bottlenecks is wrong roughly 80% of the time. Profile, hypothesise, change *one thing*, re-measure. The patterns in this skill apply only on hot paths — premature optimisation makes code worse without making it faster. ## Core Rules 1. **Profile before optimising.** `go test -bench`, `pprof`, `fgprof` — never guess. 2. **One change at a time.** Multi-change "optimisation" passes are unreviewable. 3. **Compare with `benchstat`.** Single runs lie; you need ≥6 runs to see signal. 4. **Allocation reduction usually beats CPU micro-optimisation** — the GC is fast but not free. 5. **Rule out external bottlenecks first.** If 90% of latency is the DB, faster Go code is irrelevant. 6. **Document optimisations in comments.** Future readers will revert "ugly" code without context. ## Iterative Methodology The cycle is: **define goal → write benchmark → measure baseline → diagnose → improve one thing → re-measure → commit with the diff.** ```bash # baseline go test -bench=BenchmarkHotPath -benchmem -count=6 ./pkg/... | tee /tmp/report-1.txt # (apply ONE change) # compare go test -bench=BenchmarkHotPath -benchmem -count=6 ./pkg/... | tee /tmp/report-2.txt benchstat /tmp/report-1.txt /tmp/report-2.txt ``` If `benchstat` shows no statistically significant change, the optimisation didn't work — revert it. Keep the `/tmp/report-*.txt` files as an audit trail; paste the `benchstat` output in th...

Details

Author
muratmirgun
Repository
muratmirgun/gophers
Created
2 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category