Diff two Go heap profiles and see what grew, what shrank, and what disappeared. One command, plain text (plus optional JSON and HTML).
pprof-diff before.prof after.prof --top 20 --by leaf
pprof-diff
==========
Top regressions (bytes)
-----------------------
1 main.leaky +120.0 KiB bytes +30 objs
Top improvements (bytes)
------------------------
(none)
Disappeared since before
------------------------
1 runtime.mallocgc -512 B bytes -2 objs
New since before
----------------
1 bufio.NewReaderSize +24.0 KiB bytes +6 objs
go tool pprof -base=before after is the right tool for interactive investigation. pprof-diff is for when you want a fixed report: paste into a PR, gate CI on a text diff, or answer "what changed?" without opening the pprof TUI.
| pprof-diff | go tool pprof -base |
|
|---|---|---|
| Text diff report | yes | via top / export |
| JSON / static HTML / web viewer | yes | no |
| Flame graphs | no | yes |
| Single static binary | yes (D) | via Go install |
git clone https://github.com/1rhino2/pprof-diff.git
cd pprof-diff
dub build --build=releaseBinary: .dub/pprof-diff.exe (path varies by platform) or run with dub run --.
pprof-diff before.prof after.prof [options]
| Option | Default | Description |
|---|---|---|
--top N |
20 | Max rows per section |
--by stack |
stack | Group by full stack, leaf, or rough type |
--json path |
Write machine-readable diff | |
--html path |
Write single-page HTML table |
Live demo: https://1rhino2.github.io/pprof-diff/
- Run
pprof-diff before.prof after.prof --json report.json - Open the site and choose Open diff.json, or use Load demo
The site only reads JSON produced by the CLI (no .prof upload in the browser).
dub run --config=gen-examples
dub run -- examples/before.prof examples/after.prof --top 10
dub run -- examples/before.prof examples/after.prof --html examples/report.html --json examples/diff.jsoncd examples/go
go run leak.go
cd ../..
dub run -- examples/go/before.prof examples/go/after.prof --by leafFrom tests or production:
go test -memprofile=before.prof -run=YourBench .
# change code
go test -memprofile=after.prof -run=YourBench .
pprof-diff before.prof after.prof --top 30Profiles must be pprof protobuf (gzip-compressed .prof from Go is supported).
- Gunzip if the file starts with
1F 8B. - Decode the
Profilemessage (subset of google/pprof; unknown fields skipped). - Pick
inuse_objects/inuse_spacecolumns when present. - Aggregate by stack key, diff before vs after, sort by byte delta.
See proto/profile.proto for the wire schema.
.\build.ps1 # release build, tests, regenerate examples
dub run --config=golden-test- Optimized for heap profiles (object count + bytes). CPU and other profile types are best-effort.
- Symbol quality depends on the profile (stripped binaries give weaker names).
- For deep dives, use
go tool pprof.
MIT. See LICENSE.