Ask Your Question
0

Profiling python code with valgrind produces empty log file

asked 2020-03-26 16:24:18 -0500

highWaters gravatar image

updated 2020-03-27 03:53:25 -0500

Hi all,

I am running 12 ROS nodes (ROS kinetic) and starting the system with a roslaunch file. I would like to profile one of the nodes, while the whol system is running. From my search it seems that I can use valgrind.

I set the roslaunch file as below (as shown here):

<launch>
<param name="use_sim_time" value="true"/>
<arg name="seedval"/>
<param name="seed" value="$(arg seedval)"/>

<group ns="robot1">
<node pkg="pkg_name" name="agent" type="agent.py" launch-prefix="valgrind --tool=callgrind --separate-threads=yes --callgrind-out-file='callgrind.sim1.%p'">
<param name="myID" value="1"/>
......
</node>
</group>

.....
</launch>

I build the package in debug mode like so:

catkin_make -DCMAKE_BUILD_TYPE=Debug

Now from what I have read, valgrind will dump the data when the program terminates. And the issue might lie here, because the nodes exit with sys.exit(), raising a SystemExit exception. I have tried adding the --dump-before=function option, but to no avail:

launch-prefix="valgrind --tool=callgrind --dump-before=name_of_function_as_in_script --separate-threads=yes --callgrind-out-file='callgrind.sim1.%p'"

Any ideas, I am not quite sure how to proceed.

Thanks!

hW

edit retag flag offensive close merge delete

Comments

Do you mean you don't have the file ~/.ros/callgrind.sim1.PID_NUMBER ?

Also I'm not sure that vallgrind can be used with python as it's said in the introduction of the tutorial :

This tutorial explains how to use profiling tools for roscpp nodes that you are launching with roslaunch.

Delb gravatar image Delb  ( 2020-03-27 03:58:58 -0500 )edit

Hi, I get the file, but it is empty. From here it seems I might have to do compile python itself in debug mode, such that it is valgrind friendly.

highWaters gravatar image highWaters  ( 2020-03-27 04:14:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-27 04:18:55 -0500

highWaters gravatar image

Ok, I had an epiphany and did the following: launch-prefix="pprofile --format callgrind --out out". I will marked this as solved.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-26 16:24:18 -0500

Seen: 18 times

Last updated: Mar 27