go-pprof-profiling
Skill0 starsChanged 39 days agoMITView on GitHub
Use when profiling Go programs with pprof — CPU hotspots, allocation rates, GC pressure, lock contention, or goroutine leaks; covers profile types (cpu/heap/block/mutex/goroutine), go tool pprof interactive commands, flat vs cum, differential profiles with -base, and sample_index for inuse vs alloc
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-deterministic-concurrency-testsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 61
Use -diff_base when run durations differ — it compares rates, not absolutes.
- Very specific: line 65
Heap sampling misses small hot allocations: default rate 512 KB. Set runtime.MemProfileRate = 1 in tests only.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go pprof Profiling
Sampling profiler. Flat = samples in the function itself; cum = samples in the function plus everything it called. Heap is approximate (1 sample per ~512 KB by default) — small hot allocations vanish.
Profile types
| Profile | Endpoint | Measures |
| cpu | /debug/pprof/profile?seconds=30 | wall-clock samples at 100 Hz |
| heap | /debug/pprof/heap | live + cumulative allocations |
| goroutine | /debug/pprof/goroutine | all goroutine stacks (leak hunt) |
| block | /debug/pprof/block | time blocked on sync primitives |
| mutex | /debug/pprof/mutex | contention on Lock/Unlock |
| trace | /debug/pprof/trace?seconds=5 | full execution trace (go tool trace) |
Block/mutex are off by default — enable at startup:
runtime.SetBlockProfileRate(1) // every blocking event
runtime.SetMutexProfileFraction(1) // every contention eventInstall endpoints: import _ "net/http/pprof" then serve on localhost:6060.
Heap sample index
-sample_index= | Units | Use for |
alloc_space | bytes allocated (lifetime) | GC pressure, hotspots |
alloc_objects | allocations (lifetime) | churn count |
inuse_space | live bytes (default) | heap footprint |
inuse_objects | live objects | leak candidates |
Allocation hotspots are invisible in the default inuse_space view — switch to alloc_objects.
Interactive commands
| Command | What |
top / top -cum | rank by flat / cumulative |
list FuncRE | source lines with sample counts |
weblist FuncRE | source + disasm in browser |
peek FuncRE | callers and callees |
focus=RE / ignore=RE / hide=RE | regex filter on stack |
tagfocus=k=v | filter on profile labels |
nodefraction=0.05 | hide nodes <5% cumulative |
Differential profiling
go tool pprof -base v1.pb.gz v2.pb.gz # subtract; negatives = improvements
go tool pprof -diff_base v1.pb.gz v2.pb.gz # subtract then normalize to zero total
go tool pprof -http=localhost:8080 -base v1 v2Use -diff_base when run durations differ — it compares rates, not absolutes.
Pitfalls
- Heap sampling misses small hot allocations: default rate 512 KB. Set
runtime.MemProfileRate = 1in tests only. - Inlining hides callees: inlined functions vanish; samples attribute to the caller. Use
listfor per-line, or//go:noinlinewhile profiling. -httpbinds all interfaces: pass-http=localhost:8080or the UI is exposed externally.- CPU frequency scaling skews timing: pin governor to performance for reproducible CPU profiles.
- Unoptimized binary:
-gcflags=all=-N -lproduces misleading hotspots — profile optimized builds only. -basewith different sample rates: heap profiles must shareMemProfileRate, or the diff is meaningless.goroutineprofile is stop-the-world: expensive on busy servers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

