# Optimize Go Performance With Profiling

Go services often slow down from allocations, GC pressure, I/O waits, or inefficient hot paths. This skill maps profiling signals to focused Go performance fixes and benchmark validation.

## Install

```bash
npx skillstore add samber/golang-performance
```

## Metadata

- Status: approved
- Slug: samber-golang-performance
- Version: 1.2.2
- Author version: 1.2.2
- Skillstore revision: r1
- Version status: valid
- Tree hash: 31af43c9b61bdb9522abf679aa427448eb3ae5a96cd19ffe4e2c0c612faf6034
- Author: samber
- GitHub username: samber
- License: MIT
- Repository: https://github.com/samber/cc-skills-golang/tree/main/skills/golang-performance/
- Ref: e397ce5a135369cd6def89cb6400d013e2f68f2f
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network, filesystem
- Quality score: 81
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/samber-golang-performance
- Manifest: https://skillstore.pages.dev/api/skills/samber-golang-performance/manifest

## Capabilities

- Maps pprof, fgprof, trace, and benchmark signals to specific Go optimization patterns.
- Guides allocation reduction, slice reuse, map sizing, pooling, and backing array fixes.
- Explains CPU hot-path improvements, cache locality, inlining, false sharing, and SIMD tradeoffs.
- Covers runtime tuning for GC, GOMEMLIMIT, GOMAXPROCS, and profile-guided optimization.
- Provides review guidance for I/O, networking, caching, batching, and observability regressions.

## Use Cases

- Review a Slow API Handler: Identify whether latency comes from Go code, database calls, network waits, allocations, or JSON overhead.
- Reduce Allocation Pressure: Use heap profiles and benchmarks to choose slice, map, pooling, or copy strategies.
- Prevent Performance Regressions: Add benchmark comparisons, Prometheus checks, and documentation for optimized hot paths.

## Prompt Templates

### Start With Profiling

```
My Go service is slow, but I do not know the bottleneck. Help me choose profiling steps before changing code.
```

### Analyze Heap Pressure

```
I have a heap profile showing high allocations in a Go function. Explain likely causes and propose one benchmarked change at a time.
```

### Optimize a Hot Path

```
This Go function dominates CPU time in pprof. Review it for inlining, cache locality, allocation, and algorithmic improvements.
```

### Design Regression Checks

```
Help me create benchmark, benchstat, and observability checks that catch Go performance regressions before release.
```

## Limitations

- Requires profiling data or a clearly identified bottleneck for best results.
- Does not replace production load testing or statistically sound benchmarks.
- Go tool availability depends on the local project environment.
- External service, database, or infrastructure bottlenecks may need other skills.

## Best Practices

- Profile first, choose one hypothesis, change one thing, and compare with benchstat.
- Prefer allocation reduction and algorithmic fixes before runtime tuning or unsafe code.
- Document optimized hot paths with benchmark numbers and the reason for the pattern.

## Anti Patterns

- Optimizing code from intuition without pprof, tracing, or benchmark evidence.
- Applying many performance changes at once without isolating the effect of each change.
- Using unsafe, pooling, or SIMD before proving a measured hot-path benefit.

## Security Audit

- Audited at: 2026-07-06T20:56:01.885\+00:00
- Summary: All static findings were adjudicated as false positives. The matches occur in Markdown documentation, JSON evaluation prompts, example Go snippets, local profiling commands, or project metadata, with no evidence of malicious execution, exfiltration, prompt injection, or unauthorized file access.

## Stats

- Views: 0
- Downloads: 5
- Favorites: 0
- Popularity score: 0
