Multi-threaded performance analysis using Valgrind's Callgrind tool
Yum Install Valgrind
/
wget http://valgrind.org/downloads/valgrind-3.4.1.tar.bz2
Tar xvf valgrind-3.4.1.tar.bz2
CD VALGRIND-3.4.1/
./configure--prefix=/usr/local/webserver/valgrind
Make
Make install
Brief introduction
Valgrind is an open source performance analysis tool. Based on its documentation, you can use it to check for problems such as memory leaks, and also to generate call graphs for functions that are attractive enough for these two functions.
This article is mainly about how to use Valgrind's Callgrind tool for performance analysis.
Profiling process using the Callgrind tool to generate profiling data
The command format is as follows:
Valgrind--tool=callgrind ls
Where LS is the program we want to analyze. Once execution is complete, a file is generated in the current directory. The file is named "Callgrind.out. Process number". For example, callgrind.out.3478-01. Note that for daemon process debugging, do not stop by kill-9 mode.
If you are debugging a multi-threaded program, you can also add a parameter-separate-threads=yes to the command line. This will generate a separate profiling file for each thread. As follows:
Valgrind--tool=callgrind--separate-threads=yes ls
The resulting file will also have a number of sub-threading files in addition to callgrind.out.31113. The file name is as follows:
callgrind.out.31113-01 callgrind.out.31113-02 callgrind.out.31113-03
Convert Callgrind generated performance data into dot format data
You can use the gprof2dot.py script to convert the performance analysis data generated by callgrind into dot format data. It is easy to use dot to graphically visualize analytical data.
The script can click this download. Scripts are used in the following ways:
Python gprof2dot.py-f callgrind-n10-s callgrind.out.3478-01 >1.dot using dot to generate images
The command format is as follows:
Yum Install Graphviz
Dot-tpng 1.dot-o 1.png Why--------------------------------------------------------------------------------------------- 2016-06-0811:10:25
Valgrind Print Program Call Tree + multi-threaded performance analysis