-
Notifications
You must be signed in to change notification settings - Fork 120
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
[Galactic] Loan messages implementation #547
Conversation
* Added is_plain_ attribute to base TypeSupport. * Added new methods to base TypeSupport. * Implementation of rmw_borrow_loaned_message. * Implementation of rmw_return_loaned_message_from_publisher. * Enable loan messages on publishers of plain types. * Implementation for taking loaned messages. * Enable loan messages on subscriptions of plain types. Signed-off-by: Miguel Company <[email protected]> Co-authored-by: Michel Hidalgo <[email protected]>
Signed-off-by: Miguel Company <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. I'd like to hear @cottsay thoughts on backporting this though.
@@ -50,6 +56,7 @@ struct CustomSubscriberInfo : public CustomEventInfo | |||
const void * type_support_impl_{nullptr}; | |||
rmw_gid_t subscription_gid_{}; | |||
const char * typesupport_identifier_{nullptr}; | |||
std::shared_ptr<rmw_fastrtps_shared_cpp::LoanManager> loan_manager_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiguelCompany I know these bits are in a grey area when it comes to code visibility but this isn't ABI compatible, strictly speaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, strictly speaking. But rmw_fastrtps_shared_cpp
is designed to be only used by rmw_fastrtps_cpp
and rmw_fastrtps_dynamic_cpp
, which this PR is also modifying. This means ABI is kept to the users of the RMW.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a clearer definition of "public" here. Please correct me if I'm mistaken but as I understand it, this will technically break ABI compatibility even if you don't intend for this struct to be part of the formal rmw_fastrtps*
public API. By that, I mean that if we publish this, and I apt update ros-rolling-rmw-fastrtps-shared-cpp
without updating the consumers of that package, the consumers won't allocate adequate space for this struct but code in rmw_fastrtps_shared_cpp
will try to access it anyway.
One can blur the lines of what constitutes "public API" by claiming that not everything exposed in the headers are formally part of the API, but the linker doesn't care what we say. ABI is ABI, and when you change the size of a struct, it is no longer compatible.
I'm going to bring this up at the next ROS 2 meeting so that we can get some solid documentation on the matter and clearly define our goals regarding ABI stability within a rosdistro so that we can come up with some criteria for when we can break it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new field is added at the end, so offsets of the old fields are not modified. The new field is only being accessed from new functions of rmw_fastrtps_shared_cpp
. This means that consumers which are not updated will not be calling code accessing the new field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this at the ROS 2 meeting, and it sounds like stability among arbitrary combinations of package updates isn't part of our ABI stability goal, so my concerns are no longer valid. Thanks for your patience.
auto item = loan_mgr->items.emplace_back(); | ||
if (nullptr == item) { | ||
RMW_SET_ERROR_MSG("Out of resources for loaned message info"); | ||
return RMW_RET_ERROR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiguelCompany nit: RMW_RET_BAD_ALLOC
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 1332adb
Signed-off-by: Miguel Company <[email protected]>
cbca746
to
f92e78f
Compare
Signed-off-by: Miguel Company <[email protected]>
f92e78f
to
c61c214
Compare
@@ -47,6 +47,7 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members) | |||
|
|||
// Total size is encapsulation size + data size | |||
m_typeSize = 4 + data_size; | |||
m_typeSize = (m_typeSize + 3) & ~3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiguelCompany mind to explain this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hidmic
TL/DR: Account for RTPS sub-message alignment
The DDSI-RTPS spec requires each submessage to be aligned on a 4-byte boundary. This means that, when using PREALLOCATED
memory policy, we could receive a serialized payload bigger than m_typeSize
, which would thus be discarded. When using the rmw's default PREALLOCATED_WITH_REALLOC
memory policy, an unnecessary reallocation could happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments on f40ff2d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. How is this not a problem on master
? Upstream Fast-DDS differences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Miguel Company <[email protected]>
Alright, this is good to go. @cottsay ? |
Beyond the one ABI break discussed above, this seems like a straightforward feature addition, so 👍 from me. I'd like to hold off on merging until we discuss it at the ROS 2 meeting on Tuesday, however. |
@@ -50,6 +56,7 @@ struct CustomSubscriberInfo : public CustomEventInfo | |||
const void * type_support_impl_{nullptr}; | |||
rmw_gid_t subscription_gid_{}; | |||
const char * typesupport_identifier_{nullptr}; | |||
std::shared_ptr<rmw_fastrtps_shared_cpp::LoanManager> loan_manager_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this at the ROS 2 meeting, and it sounds like stability among arbitrary combinations of package updates isn't part of our ABI stability goal, so my concerns are no longer valid. Thanks for your patience.
Alright. Going in! Thanks for double-checking @cottsay. |
* Loan messages implementation (ros2#523) * Added is_plain_ attribute to base TypeSupport. * Added new methods to base TypeSupport. * Implementation of rmw_borrow_loaned_message. * Implementation of rmw_return_loaned_message_from_publisher. * Enable loan messages on publishers of plain types. * Implementation for taking loaned messages. * Enable loan messages on subscriptions of plain types. Signed-off-by: Miguel Company <[email protected]> Co-authored-by: Michel Hidalgo <[email protected]> * Changes to work with galactic type support. Signed-off-by: Miguel Company <[email protected]> * Improve return code. Signed-off-by: Miguel Company <[email protected]> * Prepare type size for alignment requirements. Signed-off-by: Miguel Company <[email protected]> * Add comments on alignment code. Signed-off-by: Miguel Company <[email protected]> Co-authored-by: Michel Hidalgo <[email protected]>
This is a backport of #523 into galactic without the need of ros2/rosidl_typesupport_fastrtps#67