Format of google-perftools/pprof with heap profiling

3k views Asked by At

There is a pprof utility in google-perftools package. It is utility to convert profile files from google-perftools cpuprofiler and heapprofiler into beautiful images: like https://github.com/gperftools/gperftools/tree/master/doc/pprof-test-big.gif and https://github.com/gperftools/gperftools/tree/master/doc/heap-example1.png

The format of pprof's input file is described for cpu profiles here: https://github.com/gperftools/gperftools/tree/master/doc/cpuprofile-fileformat.html

but the format of heap profile input files is not described in the svn.

What is the "heapprofiling" format and how can I generate such file from my code? I already can generate cpuprofiler format, so I interested what are the difference between two formats.

1

There are 1 answers

3
osgx On BEST ANSWER

Seems the format is not binary as for cpu profiler, but textual:

First line:

 heap profile:   1:   2 [ 3:  4] @ heapprofile

Regex (not full)

 (\d+): (\d+) \[(\d+): (\d+)\] @ ([^/]*)(/(\d+))?)?

where

  • 1 & 2 is "in-use stats"; first number is count of allocations, second is byte count
  • 3 & 4 is "total allocated stats"; first and second with same meaning
  • heapprofile is the type

Then a profile itself follows in lot of lines:

 1: 2 [ 3: 4] @ 0x00001 0x00002 0x00003

where "1: 2" and "3: 4" is of the same meaning as in first line; but only malloced from given callsite; 0x00001 0x00002 is callstack of the callsite.

Then empty line and "MAPPED_LIBRARIES:". From the next line something very like copy of the /proc/pid/maps follows.