Skip to content
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

Allow loaned messages without data-sharing #568

Merged
merged 3 commits into from
Jan 14, 2023

Conversation

MiguelCompany
Copy link
Contributor

The only requirement on the Fast DDS API in order for loans to be used is that the type is plain.

This PR allows calling the loan APIs when data-sharing is OFF.
This enables performance improvements on intra-process and UDP.

@richiware
Copy link
Contributor

Maybe definition of using DataSharingKind is not already needed like in file publisher.cpp.

@fujitatomoya
Copy link
Collaborator

CI: (only rmw_fastrtps)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@MiguelCompany
Copy link
Contributor Author

@fujitatomoya Would you mind triggering CI again on this PR?

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

@MiguelCompany still unstable, could you check the log?

@clalancette clalancette added the more-information-needed Further information is required label Mar 3, 2022
@fujitatomoya
Copy link
Collaborator

@MiguelCompany friendly ping.

@MiguelCompany
Copy link
Contributor Author

@fujitatomoya I've been investigating the failures on rclcpp test_subscription_topic_statistics, and I've found the issue.

When using loans, method handle_loaned_message is called on the subscription instead of handle_message. See here
But class SubscriptionTopicStatistics only has an override for handle_message here

We need to add an override for handle_loaned_message on SubscriptionTopicStatistics, so statistics are also accounted for loaned messages.

@fujitatomoya
Copy link
Collaborator

CC: @Barry-Xu-2018

@fujitatomoya
Copy link
Collaborator

@Barry-Xu-2018 do we have any progress on this?

@Barry-Xu-2018
Copy link
Contributor

@fujitatomoya

I don't try it since this PR isn't merged.
#579 depends on this. So you want to check it now.

@fujitatomoya
Copy link
Collaborator

We need to add an override for handle_loaned_message on SubscriptionTopicStatistics, so statistics are also accounted for loaned messages.

i think this needs to be addressed with this PR at the same time. otherwise, we cannot have green light on CI.

@Barry-Xu-2018
Copy link
Contributor

@fujitatomoya

I try this PR and confirm message (pod) can be loaned without data-sharing enabled.

About the failures on rclcpp test_subscription_topic_statistics

We need to add an override for handle_loaned_message on SubscriptionTopicStatistics, so statistics are also accounted for loaned messages.

I have a different opinion. @MiguelCompany

For handle_message(), it has codes to get topic statistics (call handle_message() of SubscriptionTopicStatistics).
https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/subscription.hpp#L345-L349

But for handle_loaned_message(), nothing is done for statistics even if statistics is enabled. So test failed.
Therefore, we can add codes to get topic statistics, like codes in handle_message().

https://github.com/ros2/rclcpp/blob/d8e1aed520047b5da28d65cbfbdf781358c14fc6/rclcpp/include/rclcpp/subscription.hpp#L361-L371

@MiguelCompany
Copy link
Contributor Author

MiguelCompany commented May 11, 2022

@Barry-Xu-2018 I think you are right.

On my first look at the code, I thought that SubscriptionTopicStatistics was a child class of Subscription, but now I see I was wrong.

The point is what you say. Statistics should be handled when handling a loaned message.

As an extra fix, I think we should also mimic the rest of the behavior on handle_message (i.e. ignore rclcpp intraprocess processing): https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/subscription.hpp#L329-L333

@fujitatomoya
Copy link
Collaborator

@Barry-Xu-2018 ah, right what we need to do is modify Subscription::handle_loaned_message. could you work on this? i am happy to do review.

@Barry-Xu-2018
Copy link
Contributor

could you work on this? i am happy to do review.

Okay. I make it.

@Barry-Xu-2018
Copy link
Contributor

Barry-Xu-2018 commented May 12, 2022

@fujitatomoya

I created a PR ros2/rclcpp#1927.
Please help to review.

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

i thinik repo file is old, need to be rebased.

@fujitatomoya
Copy link
Collaborator

CI withhttps://gist.githubusercontent.com/fujitatomoya/f93a8b37c13378d829aaddcc24bf72f2/raw/89f243a68e8aef6d8dc92e306007e99350c00942/ros2.repos

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@MiguelCompany
Copy link
Contributor Author

i thinik repo file is old, need to be rebased.

I can rebase the branch if necessary

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
@MiguelCompany
Copy link
Contributor Author

@fujitatomoya I rebased this one.

@fujitatomoya
Copy link
Collaborator

@MiguelCompany thanks!

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@MiguelCompany
Copy link
Contributor Author

@fujitatomoya I think the failing tests are wrong, as this line should be with std::launch::async instead of std::launch::deferred, as it is done on the test above.

@fujitatomoya
Copy link
Collaborator

CI with ros2/rclcpp#1940

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

I will run whole CI for this, since this could affect many packages.

@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator

Note:

after this PR is merged, rmw_fastrtps tries to enable LoanedMessage to borrow the memory from Fast-DDS as long as message type is bounded (PoD) by default. Application is still responsible to use LoanedMessage Class to use middleware memory for zero-copy inter-process transport.

see also, #596 (comment)

@audrow audrow changed the base branch from master to rolling June 28, 2022 14:22
@MiguelCompany
Copy link
Contributor Author

@fujitatomoya Is there anything pending here?

@fujitatomoya
Copy link
Collaborator

I just need to rerun the CI, thanks for the ping.

@fujitatomoya
Copy link
Collaborator

CI (Full with rmw_fastrtps static):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya merged commit 19d141d into ros2:rolling Jan 14, 2023
@MiguelCompany MiguelCompany deleted the feature/loans-without-shm branch January 15, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed Further information is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants