Ask Your Question
0

How do I make nodelet manager as fast as the individual nodes?

asked 2016-08-22 17:57:05 -0500

gabewb gravatar image

updated 2016-08-23 13:06:30 -0500

I have two nodelets that don't talk to each other at all. Neither subscribes to anything that the other publishes. I put them under a shared nodelet manager as the first step of a larger project to integrate them with a third nodelet.

I was surprised to discover that stapling the nodes into a single nodelet manager made them slower overall, even with a really high num_worker_threads.

nodelets.launch:

    <node pkg="nodelet" type="nodelet" name="twin_nodelet_manager" args="manager"> 
        <param name="num_worker_threads" value="32" />
    </node>
    <node pkg="nodelet" type="nodelet" name="tweedledee" args="load wonderland/tweedledee twin_nodelet_manager" />
    <node pkg="nodelet" type="nodelet" name="tweedledum" args="load wonderland/tweedledum twin_nodelet_manager" />

nodes.launch:

    <node pkg="wonderland" type="tweedledee" name="tweedledee" output="screen"/>
    <node pkg="wonderland" type="tweedledum" name="tweedledum" output="screen"/>

Is this consistent with other people's experience? I assume I'm not giving the nodelet manager as much of the computer's resources as I gave the pair of nodes. Is there a way to increase that?

EDIT:

By "not as fast" I mean that the time elapsed during the main callback increased according to std::clock.

void mainCallback(msg) {
  double start = std::clock();
  // do stuff, publish
  double elapsed = ((double)std::clock() - start) / CLOCKS_PER_SEC;
  ROS_INFO_STREAM("elapsed: " << elapsed);
}
edit retag flag offensive close merge delete

Comments

How did you measure the fact, that they are slower? When you open up htop do you see them running in separate threads?

Dimitri Schachmann gravatar imageDimitri Schachmann ( 2016-08-23 05:03:21 -0500 )edit

Edited to show method used for testing. I didn't run htop to see what resources the nodelets were getting - I'll let you know what I see.

gabewb gravatar imagegabewb ( 2016-08-23 13:04:04 -0500 )edit
3

I don't think you can use std::clock() for this purpose. See this note fi (from here):

if the current process is multithreaded and more than one execution core is available, std::clock time may advance faster than wall clock.

gvdhoorn gravatar imagegvdhoorn ( 2016-08-23 13:44:52 -0500 )edit

In general I wouldn't use cpu time for benchmarking purposes.

gvdhoorn gravatar imagegvdhoorn ( 2016-08-23 13:51:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-08-23 17:29:50 -0500

gabewb gravatar image

The problem is the use of std::clock(). The nodes themselves were single-threaded, but the nodelet manager is multithreaded, which throws off std::clock() by a lot.

Switched to std::chrono::high_resolution_clock::now(), and the problem no longer appears.

Thanks, gvdhoorn!

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

2 followers

Stats

Asked: 2016-08-22 17:57:05 -0500

Seen: 838 times

Last updated: Aug 23 '16