-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid copies when combining intra-process communication and shared memory transports #2203
Comments
@alsora thanks for the summary. I think this also clears
IMO, I guess we see a few options here,
|
When dealing with communication between two entities in the same process, we have multiple communication modes:
My understanding is that currently the only way to avoid the copy of the message is to use rmw shared memory between all pubs and subs: the rmw intra-process would have the same limitation as the rclcpp intra-process in this context (this is different from the issue described in #2202, which would be solved by using rmw intra-process) |
AFAIK, Fast-DDS can already support this using CC: @MiguelCompany |
The only problem is that using loaned messages between pubs and subs in the same process is more inefficient than using intra-process optimization mechanisms.
Assuming that the communication A -> Y is done through shared memory transport, we have the following options:
Options 1) and 2) result in an extra copy of the messages, while option 3) has additional overhead due to the use of loaned message APIs. IMO all the 3 options above are currently suboptimal. To improve the situation we can either:
|
Feature request
ROS 2 supports multiple communication modes.
Consider the following scenario, with two processes:
Intra-process communication allow the publisher to send the message to subscriber X without copies.
Similarly if zero-copy shared memory transports are enabled, the publisher should be able to send the message to the subscriber Y without performing any copy.
However, the mechanism breaks when both modes are used at the same time: indeed inter and intra-process currently need different copies of the message.
Note that disabling intra-process communication is a suboptimal solution.
Indeed intra-process communication is faster and uses less CPU than shared memory transport, even if no copies are involved.
Depending on the size of the message, the performance penalty from not using intra-process comm may be larger than the overhead caused by the copy that is needed when combining the two transport modes.
However, it should be possible to get the best of both worlds when all subscribers are only interested in read-only access to the message.
This would require to essentially use the same loaned message for both inter and intra process deliveries.
The text was updated successfully, but these errors were encountered: