[Nav2] New Profiling Tutorial!

Hi all, your friendly neighborhood navigator here,

I wanted to bring to the community’s attention a new tutorial I wrote this afternoon for how to profile applications in ROS 2 with valgrind. This subject has come up a few times in the Nav2 working group while trying to analyze run-time performance and identify locations for improvements.

This tutorial focuses on the ROS-y aspects of profiling including how to profile from a launch file, ros2 run commandline, and with servers with plugins that you’d like to also profile. It ends briefly with using the profiler results in kcachegrind to see the Call Graph and analyze where in your server the time is being mostly spent.


This is certainly not an exhaustive tutorial about all the things you can do with profilers and analysis you can derive from the results, but its a good starting point for new developers that haven’t used this technology before or are just looking to bridge their existing skills into ROS 2-based projects.

This compliments the Backtrace Tutorial I made 2 years ago (wow, I feel old now :cry: ) for our to get backtraces with ROS 2.

Happy profiling,



Hey steve, clean tutorial. Will try out and post results. just a quick question. Is it obvious that the function in which code stays the most is the one using most system resources or it could be otherwise .:face_with_monocle:

1 Like


I’m not exactly sure what you’re trying to ask or I’m parsing the sentence incorrectly. Perhaps you could rephrase with more detail?

1 Like

Thanks for the tutorial! Is there any way to integrate the results of such profilers in CI? Maybe to output a warning / error in case the recent commits degraded the performance of a function below a limit…?

1 Like

It’s not using @smac’s nice work, but for benchmarking you could take a look at how tesseract does it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.