golang-performance

Diagnose and fix Go performance bottlenecks using profiling-driven optimization patterns.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-performance-verifiedorganic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-performance
Source: https://github.com/VerifiedOrganic/onboard/tree/main/.agents/skills/golang-performance
Command: npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-performance-verifiedorganic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires benchstat, and includes references (resource) components.

What problem does it solve? Go services often suffer from hidden bottlenecks — excessive allocations, GC pauses, cache misses, lock contention, or external I/O waits — and intuition about the cause is wrong most of the time. This Skill provides a disciplined, profile-first methodology that maps each identified bottleneck to the correct optimization pattern, preventing wasted effort on micro-optimizations that don't address the real problem. ## Core Features & Use Cases - Decision-tree diagnosis: Maps pprof and fgprof signals (alloc_objects, CPU profile, goroutine blocks) to the right optimization domain — memory, CPU, runtime tuning, I/O, or caching. - Iterative optimization workflow: Enforces a measure-baseline, change-one-thing, benchstat-compare cycle with statistical significance checks and audit-trail report files. - Deep-dive references: Covers allocation reduction, sync.Pool patterns, struct alignment, cache locality, false sharing, SIMD, HTTP transport tuning, JSON performance, and GC tuning with GOMEMLIMIT. - Use Case: Your Go API has p99 latency of 2s but only 5% CPU usage. The Skill directs you to fgprof for off-CPU analysis, identifies blocked goroutines on database calls, and guides connection pool tuning instead of pointless CPU micro-optimization. ## Quick Start Ask the agent to review your Go package for performance anti-patterns or to optimize a specific function that profiling has identified as a bottleneck.

Frequently Asked Questions about golang-performance

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

FAQPage Schema
How do I optimize a slow Go function?▼

Profile first with pprof to find the actual bottleneck, then write an atomic benchmark and measure a baseline with -benchmem and -count=6. Apply one optimization at a time and compare results with benchstat to confirm statistical significance before committing.

How do I reduce memory allocations in Go hot paths?▼

Reuse slice backing arrays with append(s[:0], ...), preallocate maps with size hints, use sync.Pool for frequently allocated short-lived objects, and avoid interface boxing by using typed parameters or generics. Check escape analysis with go build -gcflags="-m".

What tool should I use when Go CPU profiling shows nothing but latency is high?▼

Use fgprof, which captures both on-CPU and off-CPU time including I/O wait. Standard pprof CPU profiles only sample running goroutines, so they miss time blocked on network, database, or filesystem operations.

Does Go map memory shrink after deleting keys?▼

No, Go maps never release bucket memory when entries are deleted. A map that once held millions of entries retains its peak allocation forever. Replace the map with a fresh make() call so the old bucket array becomes eligible for garbage collection.

When should I use sync.Pool in Go?▼

Use sync.Pool for frequently allocated, short-lived objects in hot paths like HTTP handlers and serializers. Reset state before Put, return copies rather than pooled buffers, and avoid pooling objects larger than about 32KB.

Why is my Go struct using more memory than expected?▼

Field ordering causes padding bytes for alignment requirements. Reorder fields from largest to smallest (int64 and float64 first, bools last) and run the fieldalignment tool to detect structs with wasted padding automatically.