How to generate differential flame graph of two go pprof files?

573 Views Asked by At

I have been working on profiling a golang program and trying to generate differential flame graph of two pprof files.

Steps:

  1. generate first.pprof file
  2. improve code, then generate second.pprof file
  3. ./stackcollapse-go.pl first.pprof > before.folded

But it seems that the stackcollapse-go.pl does not work as I expected, the before.folded is empty.

So what's the right way to generate differential flame graph of go program?

1

There are 1 best solutions below

0
On

stackcollapse-go.pl doesn't take in the raw protobuf. You need to translate your .pprof into the right textual format.

So first we get the raw data, suitable for passing to stackcollapse-go.pl

$ go tool  pprof -raw first.pprof > first.raw

Now we can pass it through stackcollapse-go.pl

$ ./stackcollapse-go.pl first.raw > first.collapsed 

You can then use the flamegraph.pl script to get the final svg

./flamegraph.pl first.collapsed > first.svg