Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Valgrind

Andy Pavlo edited this page May 22, 2019 · 2 revisions

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

Memory Leaks

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

valgrind --trace-children=yes --track-origins=yes terrier -port 15721

valgrind --trace-children=yes --track-origins=yes ./debug/bitmap_test

Profiling

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

    valgrind --tool=callgrind --trace-children=yes terrier &> /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 terrier -port 15721

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.