ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
13

Catkin-compiled Code Runs 3x slower

asked 2013-08-09 08:09:07 -0500

David Lu gravatar image

updated 2013-11-18 16:53:19 -0500

tfoote gravatar image

I've been running a slate of tests on the new hydro navigation. I was trying to figure out why updating the costmap in the new hydro version takes so much longer than in the old 'Fuerte' version. (Note that both of these are tested in Groovy)

I searched and searched to figure out how the new code was different. But it wasn't the code at all. It was the compiler.

graph of runtimes

The colors of each segment of the bar are irrelevant in this case. The first row shows how long the catkin-compiled version of the Hydro code takes to update the costmap once. The second bar shows the same operation in Fuerte, which is compiled using Rosbuild. The third is the same exact code from the first bar, but compiled using Rosbuild.

My question is: what accounts for this 3x slowdown when compiling with Catkin?

Links:

Edit: The benchmark was performed using locally compiled packages and the timing was measured with repeated gettimeofday calls (since that infrastructure was already in the code for measuring update-time.)

Edit 2: Thanks to William's comment, I figured it out. another chart

Explanation: The update loop timing is usually only available in the ROS_DEBUG information. Printing the DEBUG logs takes a bit of time, which you can see with the red bars. For the packages I compiled, I also changed it to be printed quicker without ROS_DEBUG. However, I couldn't do that for the debian package.

The key result is that Rosbuild code (which William mentions, already was built in Release mode) runs as fast as the catkin code with the release flag set.

I don't know why the Debian is as slow as it is, but its not going to bother me immediately.

(@William: Put your answer below for some sweet sweet karma)

edit retag flag offensive close merge delete

Comments

Can you describe how you did the benchmark? Did you compiled the packages locally from source? Did you used the available Debian packages?

Dirk Thomas gravatar imageDirk Thomas ( 2013-08-09 08:52:32 -0500 )edit

Can you please post a comparison between the locally self-built package in Hydro vs. the publically available Debian package?

Dirk Thomas gravatar imageDirk Thomas ( 2013-08-09 11:14:40 -0500 )edit

Working on the tests, but a quick note: The set(ROS_BUILD_TYPE Release) line isn't mine. It's Eitan's from 2009. https://github.com/DLu/navigation/commit/fa4430e4780453d69150d8a8b40d7f427970950f

David Lu gravatar imageDavid Lu ( 2013-08-09 12:43:27 -0500 )edit

@David Lu, sure it is actually part of the default rosbuild CMakeLists.txt template.

William gravatar imageWilliam ( 2013-08-09 13:13:20 -0500 )edit

When I install ros hydro on my pc, it already comes with the navigation stack. Is the code compiled with catkin without the flag set to Release? How can I compile it with the flag?

mateus03 gravatar imagemateus03 ( 2014-07-18 06:29:24 -0500 )edit
2

Yes - all packages built on the build farm are compiled in release mode.

ahendrix gravatar imageahendrix ( 2014-07-19 19:46:59 -0500 )edit

Ok, thank you

mateus03 gravatar imagemateus03 ( 2014-07-20 06:11:21 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
10

answered 2013-08-09 13:39:22 -0500

David Lu gravatar image

Just to reiterate, be mindful of the ROS_BUILD_TYPE, whether set by default in your CMake or invoked on the command line. Compiling with

catkin_make -DCMAKE_BUILD_TYPE=Release

will ensure that your Catkin code is as fast as possible.

edit flag offensive delete link more

Comments

4

Just for the record these are the default build flags with CMake and if not defined CMake will use "none":

None: *no flags*
Debug: -g
Release: -O3 -DNDEBUG
RelWithDebInfo: -O2 -g
MinSizeRel: -Os -DNDEBUG
Dirk Thomas gravatar imageDirk Thomas ( 2013-08-09 15:44:23 -0500 )edit
2

As a side note, do you realize how low the probability of me memorizing that exact flag configuration is? For such an important functionality, it seems like a relatively arcane incantation.

David Lu gravatar imageDavid Lu ( 2013-08-11 09:09:19 -0500 )edit

That is why CMake uses reasonable default flags for the different build types. And catkin_make provides completion on arguments like "-DCMAKE_BUILD_TYPE" since they are not that memorable.

Dirk Thomas gravatar imageDirk Thomas ( 2013-08-11 19:46:52 -0500 )edit

It works! It took me a week to figure this out. Thanks alot!

K_Yousif gravatar imageK_Yousif ( 2013-10-13 14:47:22 -0500 )edit
3

answered 2013-08-09 11:33:50 -0500

William gravatar image

In your rosbuild CMake you do `set(ROS_BUILD_TYPE Release)`, the equivalent variable in CMake is `CMAKE_BUILD_TYPE`, but it is not good form to put that into the CMakeLists.txt directly because then it cannot be overridden externally. Try the timing tests with `catkin_make -DCMAKE_BUILD_TYPE=Release`.

edit flag offensive delete link more

Comments

1

I realize this is a very old thread, but if you do want to specify a default CMAKE_BUILD_TYPE flag in your CMakeLists.txt, you can do it safely with

if(NOT CMAKE_BUILD_TYPE) 
    set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
Greydon gravatar imageGreydon ( 2017-08-17 13:33:13 -0500 )edit

Your Answer

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

Add Answer

Question Tools

7 followers

Stats

Asked: 2013-08-09 08:09:07 -0500

Seen: 4,736 times

Last updated: Aug 09 '13