Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Valgrind

Tianyi Chen edited this page Jun 19, 2017 · 6 revisions

Valgrind

Valgrind is useful for performing dynamic analysis. Valgrind tools can automatically detect many memory management and threading bugs, and profile Peloton in detail.

Memory Leaks

Here's the command for using memcheck for detecting common memory errors.

valgrind --trace-children=yes --track-origins=yes peloton -port 54321

valgrind --trace-children=yes --track-origins=yes ./test/catalog_test

Profiling

Here's the command for using callgrind for profiling Peloton.

    valgrind --tool=callgrind --trace-children=yes peloton &> /dev/null &

You can use kcachegrind for viewing the collected profile files (i.e. the callgrind.out.* files).

    kcachegrind

Profiling a portion of execution

Suppose you want the Callgrind graph for a feature you implemented but the graph is getting skewed by other heavier options such as Inserts, you can turn profiling on/off during runtime through the following steps -

First Launch Valgrind and turn off instrumentation at start

valgrind --tool=callgrind --trace-children=yes --instr-atstart=no peloton -port 54321

When you want to start instrumentation, execute the following command on another shell window

   callgrind_control -i on

Once you're done instrumenting, you can turn it off by running

   callgrind_control -i off

You can turn on/off instrumentation multiple times within the same Valgrind session.

Clone this wiki locally