Valgrind Print Program Call Tree + multi-threaded performance analysis

Source: Internet
Author: User
Tags valgrind

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.