Ask Your Question

Nodelet performance vs number of instances

asked 2017-04-20 04:15:05 -0500

mkreddy477 gravatar image

updated 2017-04-20 05:03:34 -0500


If I launch 2 instances of a nodelet what will be the impact on the performance. Let's say the single instance of the nodelet was running at 30Hz. what will happen if multiple instances of the same nodlet was launched through a manager. I have observed a considerable amount of performance drop in the performance when two or more instances of nodelet was launched.

Please clarify me. If there is any performance issue how can I resolve the same.? Is there a way to affinitise the each instance of the nodelet to a specific core.?

Thanks in advance

edit retag flag offensive close merge delete


Because nodelets all run in the same process, they must all run on the same core.

Geoff gravatar image Geoff  ( 2017-04-20 20:39:51 -0500 )edit

Geoff, there's a thread pool, so multiple instances of a nodelet will run in parallel on a multi-core processor. I regularly do so, and as long as you avoid global variables and don't lock out global resources (CUDA in my case) things will run happily.

KenYN gravatar image KenYN  ( 2020-09-24 05:58:44 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2017-05-01 22:46:33 -0500

mkreddy477 gravatar image

I was able to solve the issue to some extent by using ros::MultiThreadedSpinner

edit flag offensive delete link more

answered 2020-09-24 02:14:13 -0500

AlexisTM gravatar image

It is even worse when you run the identical nodelet.

When using a singlethreaded executor, you will have to call the first callback (nodelet 1), and only when the first ended, you can call the second nodelet (nodelet 2) with the same data.

If you are running on a single CPU or a single-threaded executor, you will end up multiplying the time of execution by AT LEAST the number of nodelets you have.

In a practical case, this should not happen as you are not supposed to have identical nodelets running (except if in different namespaces).

Of course, having multiple nodelets in a single-threaded context will reduce the overall performance of your system by the extra processing to do.

edit flag offensive delete link more

answered 2017-04-20 20:42:25 -0500

Geoff gravatar image

If you launch two instances of the same nodelet and they perform identical processing on identical data, then it is natural that combined they would use twice the CPU time as one instance. You need to provide more information about what you are doing and what you want to achieve. How much performance drop have you seen? What are your nodelets doing, and on what sort of data?

edit flag offensive delete link more


I have enough CPU resources to do the processing. Is there a way to affinities each instance to a seperate CPU core?

I am expecting no drop in performance. I am processing Image data in the nodelet and trying to achieve the disparity map of the image. I have observed 2x drop.

mkreddy477 gravatar image mkreddy477  ( 2017-04-21 01:34:49 -0500 )edit

The default threading model for nodelets uses a single threaded, which means that the nodelets are called in sequence. You could switch to the multi-threaded nodelet API, which would allow them to run in parallel and maybe allow you to set affinities

Geoff gravatar image Geoff  ( 2017-04-21 02:11:38 -0500 )edit

I have tried using the multi-threaded nodelet API which is also has the same behaviour. I also tried passing (true) to the nodelet manager, I didn't observe any difference.

mkreddy477 gravatar image mkreddy477  ( 2017-04-27 00:34:25 -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



Asked: 2017-04-20 04:15:05 -0500

Seen: 522 times

Last updated: Sep 24