Skip to content

Profiling `y3_cluster_cpp` with Google Performance Tools

jacksonodonnell edited this page Jul 10, 2018 · 3 revisions

Performance Tools?

We use the Google Performance Tools (gperftools) to profile the y3_cluster_cpp. The gperftools profiler is a sampling profiler, meaning that it lets your program run normally, but stops it at regular intervals (say, every ~5ms) to check, or 'sample' the program state. At each sample, it records the call stack, i.e. the program is in the function foo called by the function bar called by main. From the aggregate of all samples, the profiler can say that a total of 45% of the time in foo; 30% of the time program was in foo called by bar, and the other 15% called by qux, etc.

Getting started

If you have checked out and built the cosmosis-docker image before July 10, do the following:

$ cd /path/to/docker-cosmosis
$ git pull
$ sudo ./update-cosmosis-vm.sh

This will install the google perftools libraries into your docker image.

Then, to use the profiling library in running trivial_gamma_t, do the following:

$ cd /path/to/y3_cluster_cpp
$ git fetch
$ git checkout profiler-integration

And, in your docker image,

$ cd /cosmosis/comsosis-standard-library/y3_cluster_cpp
$ make
$ ./test/trivial_gamma_t 999999999
$ ./generate-pprof-pdf.sh

When you run trivial_gamma_t, it will run the sampling profiler, and at the end of the program it will dump the results to a file called y3_cluster_cpp/dump.txt. The generate-pprof-ppdf.sh script will take the data from that dump and generate a PDF flowchart called y3_cluster_cpp/google-dump.pdf.

Clone this wiki locally