ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Boost shared pointer publishing - zero copy

asked 2016-11-18 05:19:01 -0600

ROSfc gravatar image

Hello Community,

I have read that the intra process communication can be done by publishing message using boost shared pointer of the message. Then there is zero copy. Apparentely this is what makes nodelets so powerful.

  1. My question now, is this valid only for nodelets that we should publish using pointers and there is zero copy ? Is this also true between different nodes ?

  2. Also is there a requirement that the nodelets be launched from the same nodelet manager for the zero copy to be true ?

  3. Is there a way to check/test whether there is zero copy happening in my implementation or my code is using network resources ?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-18 05:41:48 -0600

gvdhoorn gravatar image

1 . My question now, is this valid only for nodelets that we should publish using pointers and there is zero copy ? Is this also true between different nodes ?

No, only nodelets can exchange pointers*, as they share the same address space (they're basically nodes mapped onto threads instead of processes)

(* this is not entirely true: with a suitable transport (such as ethzasl_message_transport) zero-copy msg exchange is also possible between nodes, but that is not out-of-the-box supported and comes with some constraints)

2 . Also is there a requirement that the nodelets be launched from the same nodelet manager for the zero copy to be true ?

yes, again because they need to share an address space. Different managers will each have their own address spaces.

3 . Is there a way to check/test whether there is zero copy happening in my implementation or my code is using network resources ?

I know of no other way than checking resource usage (ie: CPU / memory). But in most contexts where nodelets make sense, the increase in performance is so noticeable that you'll know when it's not working (this is obviously not a good way to check, but is at least something).

edit flag offensive delete link more

Comments

Thanks for the in-depth answer!

I have a follow-up comment/question about question 3: would it not be possible to check that the zero-copy has taken place by checking for equality the addresses to which the message pointers are pointing to (on the side of the publisher and each subscriber)?

jespestana gravatar image jespestana  ( 2019-02-13 03:48:26 -0600 )edit
1

Yes, theoreticall this should be possible. I'm not entirely sure (any more, it's been a while) whether there is no place in the control flow between publisher and subscriber (in nodelet) that potentially alters the address.

But in principle the pointers should be equal.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-13 03:51:28 -0600 )edit

I think so too. Thanks.

Actually, I just checked it. And yes, you get the same address on both sides of the message transport (subscriber and publisher).

jespestana gravatar image jespestana  ( 2019-02-13 03:58:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-18 05:19:01 -0600

Seen: 746 times

Last updated: Nov 18 '16