golang-performance

Profile Go applications with pprof and benchstat to optimize performance bottlenecks.

1|Updated May 27, 2026
One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-performance-dmwin72015
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-performance
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-performance
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-performance-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Golang performance skill helps you systematically improve slow or inefficient Go code by identifying the real bottleneck first and applying the most effective optimization pattern for that bottleneck.

Core Features & Use Cases

  • Profile-first optimization: Guides you to use CPU profiling and off-CPU diagnostics (e.g., fgprof) before changing code.
  • Allocation, CPU, and memory layout improvements: Covers reducing heap allocations, improving hot-path CPU efficiency, and optimizing data layout for cache locality.
  • Iterative benchmark-driven validation: Enforces an optimize loop of baseline measurement, one-change improvements, and benchstat comparisons to confirm wins.
  • Tuning and production readiness: Includes runtime tuning (GOGC, GOMEMLIMIT), pooling rules, caching patterns, and observability cross-checks to prevent regressions.

Quick Start

Use the golang-performance skill to optimize a slow handler by profiling with pprof, selecting the matching optimization playbook, and then confirming the improvement with an isolated benchmark plus benchstat comparison.

Frequently Asked Questions about golang-performance

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

FAQPage Schema
How do I identify CPU and memory bottlenecks in Go using pprof?

Go performance profiling with pprof identifies runtime bottlenecks by capturing CPU and off-CPU diagnostics, revealing allocation, I/O, and wait issues before applying targeted optimization patterns.

What is the best way to reduce heap allocations in a Go hot path?

Reducing heap allocations in a Go hot path requires profile-first analysis to pinpoint sources, then applying targeted patterns like pooling and improving data layout for cache locality.

How do I benchmark Go code changes correctly with benchstat?

Benchmarking Go code changes correctly requires a baseline measurement, making one-change-at-a-time improvements, and using benchstat comparisons to confirm performance wins and prevent regressions.

How do I tune GOGC and GOMEMLIMIT to reduce garbage collection pressure in Go?

Tuning GOGC and GOMEMLIMIT reduces garbage collection pressure by adjusting runtime limits based on profile signals, optimizing memory usage and concurrent system performance.

When should I use off-CPU profiling instead of CPU profiling in Go?

Off-CPU profiling is used when Go applications are blocked on I/O or waits, capturing time spent off the CPU, whereas standard CPU profiling targets active execution bottlenecks.

Can I use this profile-first optimization approach for Go libraries and concurrent systems?

Yes, profile-first optimization applies to performance code review and iterative hot-path improvement workflows in Go services, libraries, and concurrent systems.