Something went wrong. Try again.
Lern Go's
pprof tool with hands-on exercises. Something went wrong. Try again.
Files
Verified signature Signed by thegabriel.eu SHA256:4Bjd9DerB5SI+pUzr/KEF7me15ZMiE6kvMiikGqIi/Y Click to copy SHA
Verified signature Signed by thegabriel.eu SHA256:4Bjd9DerB5SI+pUzr/KEF7me15ZMiE6kvMiikGqIi/Y Click to copy SHA
Verified signature Signed by thegabriel.eu SHA256:4Bjd9DerB5SI+pUzr/KEF7me15ZMiE6kvMiikGqIi/Y Click to copy SHA
- Go 98%
- Nix 2%
README.md
pprof-prof #
Practice scenarios for Go's net/http/pprof endpoints. Each tutorial is a
realistic mini-service with a real bug, running under its own load, waiting to
be diagnosed with the profiler.
Authoritative spec: backlog/1-pprof-prof/spec.md.
Curriculum #
| Dir | Endpoint under study | Symptom |
|---|---|---|
00-setup |
all (guided tour) | none |
01-goroutines |
/debug/pprof/goroutine |
goroutine count climbs |
02-heap |
/debug/pprof/heap |
memory footprint climbs |
03-cpu |
/debug/pprof/profile |
a core stays pegged |
04-allocs |
/debug/pprof/allocs |
latency, healthy live heap |
05-mutex |
/debug/pprof/mutex |
requests serialize |
06-block |
/debug/pprof/block |
throughput far below capacity |
07-threadcreate |
/debug/pprof/threadcreate |
OS threads far above the workload |
08-trace |
/debug/pprof/trace |
status pings spike though the API does nothing |
99-capstone |
none (final exam) | everything at once |
Working through an exercise #
- Read the scenario's
README.md: the symptom, the run instructions, and the endpoint to practice. - Run the service with
go run ./NN-nameand let it work for a minute. - Diagnose. Fetch profiles, read them with
go tool pprof, and point at the guilty code before you openSOLUTION.md. - Compare with
SOLUTION.md: the diagnosis path, real command transcripts, and the fix as a diff.
Each scenario serves its app on localhost:8080 and /debug/pprof on
localhost:6060. Run one scenario at a time.
Environment #
Enter the dev shell for a known-good toolchain:
$ nix develop
The shell carries a C compiler, because go tool pprof is built with cgo and
fails on hosts without one. It also carries graphviz, for pprof's graph views.
Outside the shell, if go tool pprof dies with cgo: C compiler "gcc" not found, prefix the command with CGO_ENABLED=0.