agentsclimarketplace

Go pprof profiling

Skill narenaryan/agent-skills/skills/go/go-pprof-profiling

Byte-sized agent skills for giving advanced knowledge to AI agents

Install
npx -y skills add narenaryan/agent-skills --skill go-pprof-profiling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

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

SKILL.md

3.3 KB, as published. Nobody here has run it

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

ProfileEndpointMeasures
cpu/debug/pprof/profile?seconds=30wall-clock samples at 100 Hz
heap/debug/pprof/heaplive + cumulative allocations
goroutine/debug/pprof/goroutineall goroutine stacks (leak hunt)
block/debug/pprof/blocktime blocked on sync primitives
mutex/debug/pprof/mutexcontention on Lock/Unlock
trace/debug/pprof/trace?seconds=5full 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 event

Install endpoints: import _ "net/http/pprof" then serve on localhost:6060.

Heap sample index

-sample_index=UnitsUse for
alloc_spacebytes allocated (lifetime)GC pressure, hotspots
alloc_objectsallocations (lifetime)churn count
inuse_spacelive bytes (default)heap footprint
inuse_objectslive objectsleak candidates

Allocation hotspots are invisible in the default inuse_space view — switch to alloc_objects.

Interactive commands

CommandWhat
top / top -cumrank by flat / cumulative
list FuncREsource lines with sample counts
weblist FuncREsource + disasm in browser
peek FuncREcallers and callees
focus=RE / ignore=RE / hide=REregex filter on stack
tagfocus=k=vfilter on profile labels
nodefraction=0.05hide 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 v2

Use -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 = 1 in tests only.
  • Inlining hides callees: inlined functions vanish; samples attribute to the caller. Use list for per-line, or //go:noinline while profiling.
  • -http binds all interfaces: pass -http=localhost:8080 or the UI is exposed externally.
  • CPU frequency scaling skews timing: pin governor to performance for reproducible CPU profiles.
  • Unoptimized binary: -gcflags=all=-N -l produces misleading hotspots — profile optimized builds only.
  • -base with different sample rates: heap profiles must share MemProfileRate, or the diff is meaningless.
  • goroutine profile is stop-the-world: expensive on busy servers.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.