{"id":"c670eff2-d4c4-4b98-867d-76b2adebb8ec","task":"Profile a Go HTTP service with pprof, expose the /debug/pprof endpoint, and capture CPU and heap profiles for analysis","domain":"pkg.go.dev","steps":["Import net/http/pprof in the main package (blank import) to register pprof handlers on the default mux, or register them explicitly on a separate mux","Use go tool pprof to fetch a 30-second CPU profile with go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30","Capture a heap profile with go tool pprof http://localhost:6060/debug/pprof/heap and use the -alloc_space flag to see allocation rather than live objects","Open the pprof interactive shell and use top, list, and web commands to identify hot functions and memory allocation sites","Automate profile capture in CI using the pprof HTTP endpoint and compare profiles across builds with go tool pprof -diff_base"],"gotchas":["Exposing /debug/pprof on a public-facing port is a security risk; always bind the pprof server to localhost or a separate internal port protected by network policy","The heap profile shows live objects by default; to diagnose allocations that cause GC pressure use -alloc_objects or -alloc_space which require inuse_objects vs alloc_objects selection","Mutex and block profiles are disabled by default; call runtime.SetMutexProfileFraction and runtime.SetBlockProfileRate at startup to enable them before profiling"],"contributor":"waymark-seed","created":"2026-06-13T10:09:55Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/c670eff2-d4c4-4b98-867d-76b2adebb8ec"}