golang-performance

Apply profiling-first diagnosis and benchmark-driven iteration to Go performance optimization.

2|Updated Feb 12, 2024
One-click install
npx skills add https://github.com/adibfirman/dotfiles --skill golang-performance-adibfirman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-performance
Source: https://github.com/adibfirman/dotfiles/tree/main/claude/.claude/skills/technical/golang/golang-performance
Command: npx skills add https://github.com/adibfirman/dotfiles --skill golang-performance-adibfirman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you reduce latency, CPU time, and allocations in Go services by mapping identified bottlenecks to the right optimization patterns after you’ve profiled.

Core Features & Use Cases

  • Profile-first workflow: guides you to confirm whether the bottleneck is on-CPU vs off-CPU (e.g., pprof vs fgprof) before changing code.
  • Optimization decision tree: uses benchmark-and-diagnose methodology to choose the correct technique for allocations, CPU hotspots, GC pressure, I/O waits, caching, and hot-path improvements.
  • Review and remediation: supports architecture-level scanning and focused hot-path review to suggest improvements and targeted benchmarks that quantify gains.
  • Common performance anti-patterns: covers frequent pitfalls such as logging in hot loops, reflection overhead, interface boxing, backing-array retention, and cache-locality mistakes.
  • Use cases: performance code review, designing an optimization plan after pprof/benchmarks reveal the issue, and selecting benchmark methodology to validate improvements without regressions.

Quick Start

Ask an AI assistant to: profile my Go service first (pprof/fgprof as appropriate), then choose the best single optimization pattern for the detected bottleneck, implement one change, and verify the improvement with benchstat.

Frequently Asked Questions about golang-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize Go performance after profiling reveals a bottleneck?

To optimize Go performance, profile first to confirm if the bottleneck is on-CPU or off-CPU, then apply one atomic change targeting allocations, CPU hot loops, or I/O waits, and validate the improvement using benchstat for statistically significant comparisons.

What is the best way to reduce allocations and GC pressure in Go services?

Reducing allocations and GC pressure in Go requires profiling with pprof to detect hot spots, then applying targeted optimization patterns like avoiding interface boxing or backing-array retention, and verifying the reduction with benchmark-driven iteration.

How do I diagnose off-CPU wait times versus CPU hot loops in Go?

Diagnosing off-CPU waits versus CPU hot loops in Go requires a profile-first workflow using fgprof for off-CPU waits and pprof for on-CPU hot loops to accurately pinpoint the bottleneck class before modifying code.

What common Go performance anti-patterns should I look for during a code review?

Common Go performance anti-patterns to look for during code review include logging in hot loops, reflection overhead, interface boxing, backing-array retention, and cache-locality mistakes that degrade hot-path efficiency.

How do I validate Go benchmark improvements without regressions?

To validate Go benchmark improvements without regressions, measure a baseline before changing code, apply one atomic optimization, and use benchstat to run statistically significant benchmark comparisons proving the performance gain.