-
Notifications
You must be signed in to change notification settings - Fork 68
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
API for pre-allocating messages in the middleware #159
Comments
/cc @dejanpan |
@serge-nikulin @deeplearningrobotics FYI. Can you please review @mjcarroll proposal and leave a feedback? |
The design looks good to me. Of course, during the actual use, I might want some additions or changes but that would be a separate issue. Regarding bounds violation, I vote for an error return. I am not sure what "allow retry" means. |
@mjcarroll, @wjwwood, @dejanpan, @serge-nikulin: Is there a higher level architecture overview regarding this feature? I think we need to first specify how this API should, for example, look like on a As a side note: If you plan to cast a |
@serge-nikulin Allow retry would be a best-effort at preallocating, so I believe it would be unsuitable for any sort of no allocations allowed. It would essentially allow the publication or subscription to allocate more memory if the message violated any of the bounds. I envisioned it as more of a convenience for users who had a good guess at message sizes a priori. |
@deeplearningrobotics There isn't one at the moment, but I can put one together to help clarify what it would look like from the |
Just for further reference. Memory allocation and frees were found on rmw_publish and rmw_take. |
@gonzodepedro Any update on this issue? I know you've been working on pr's but can you summarize what's left to be done in a comment here? |
So far we have preallocation for connext publish and subscribe, with bounded and unbounded sequences. To be done:
|
This broke master build, mikaelarguedas/rclpy@f55005f |
Thanks for the heads up, ros2/rclpy#337 should fix it. |
Feature request
Feature description
In order to reduce dynamic memory allocations during publish and receipt of messages during the operation of a Node, this API would ideally allow for users of the RMW API to request the middleware to preallocate memory for predefined message types and sizes.
Implementation considerations
Implement a struct that hides the implementation of the buffer allocation that future calls to
publish
will take as an argument. If a publisher is called with the argument, then it will use the previously-allocated buffer rather than allocating a new one as necessary.These can then be used by the
rmw_publish
andrmw_subscription
methods to provide a reserved space for serializing/deserializing incoming/outgoing messages.Before any messages were
publish
ortake
, these would need to be initialized via an API as follows:This will also required additional information from the typesupport to get the serialized message sizes, also taking into account the potential size of unbounded fields. To account for unbounded fields, I propose adding a second structure
rosidl_message_bounds_t
that will give the user a way of specifying known fixed bounds for unbounded messages.For fixed and bounded sized messages, the API should take a
const rosidl_message_typesupport_t*
which will then be allocated by the RMW implementation.The
rosidl_message_bounds_t
structure would be on a per message basis and describe any of the unbounded fields. Besides the nominal case, there are three main cases to handle.Serialized length can be retrieved via:
These structures can then be used in conjunction with
rmw_publisher
:Or with
rmw_subscriber
:Open Questions:
The text was updated successfully, but these errors were encountered: