-
Notifications
You must be signed in to change notification settings - Fork 116
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
Strange RAM usage when creating subscriptions #257
Comments
Please include an example which exact executable you are running. When looking at the |
Yes exactly. Similarly I tested if the issue was present for publishers, i.e. only calling |
So when running e.g. just the |
Values are always constant in time. The problem is that I would expect them to be also more or less invariant to the type of message. The value I see with There is a very strange high memory usage for some subscriptions in the range 50kb 450kb. I'm using the official Crystal docker image. |
Which RMW implementation are these for? FastRTPS or Connext? |
Fastrtps.. With opensplice the memory usage for the same tests is almost invariant. |
I can't reproduce the numbers on my end - all pub/sub binaries have a memory usage of ~ 9-10 MiB. One thing to keep in mind is that when creating publishers and subscribers the RMW impl. might choose to preallocate a number of message instances. That is usually limited to smaller messages where as larger messages might only be allocated dynamically. That might be a reason for your drop in the plot. |
That's very interesting. However I tested again the nodes on a fresh Ubuntu 18.04 system, installing the latest Debian packages and I still see the issue. I first noticed this problem on an ARMv7 platform where I was still getting 11MB for most of the nodes, except for a subscription to a statically allocated 77KB message which was taking 18MB. |
Hi @alsora Fast-RTPS will by default pre-allocate space for 100 message instances. You can change this behavior using an XML file. By default, Fast-RTPS will look for You coud start with this simple example: <?xml version="1.0" encoding="UTF-8" ?>
<dds>
<profiles>
<!--
Please note that rmw_fastrtps will only use the profile marked as default,
so is_default_profile attribute here should be true
-->
<subscriber profile_name="test_subscriber_profile" is_default_profile="true">
<topic>
<resourceLimitsQos>
<!-- Number of message instances initially allocated. Default is 100. -->
<allocated_samples>0</allocated_samples>
<!--
Maximum number of message instances allocated. 0 means no limit.
Default is 5000.
-->
<max_samples>0</max_samples>
</resourceLimitsQos>
</topic>
<!--
For each message instance, this indicates if memory for the seriazed payload is
preallocated or not. On ROS2, this will be overriden to PREALLOCATED_WITH_REALLOC
unless 'RMW_FASTRTPS_USE_QOS_FROM_XML=1' is defined in the environment.
Possible values:
DYNAMIC Memory is not allocated until needed.
PREALLOCATED Memory is allocated when message instances are
created and it is not allowed to grow. Useful for
fixed size messages.
PREALLOCATED_WITH_REALLOC Memory is allocated when message instances are
(default) created based on estimates on the maximum size of
the serialized payload, but it is allowed to grow
upon serialization. Useful for dynamic size messages.
-->
<historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
</subscriber>
</profiles>
</dds> |
@MiguelCompany Thank you a lot. Indeed in my plot the difference in size between a subscription to a 100 KiloBytes message and the one to a 10 bytes message was approximately 10 MegaBytes (100KB x 100 pre-allocated). @dirk-thomas are there any plans to better integrate this feature? |
Since it works well with other RMW implementation it seems to be a FastRTPS internal implementation decision (not sure if the DDS spec defines any of that behavior?). Therefore I would refer to @MiguelCompany if he can provide more context if that is something they could change in the FastRTPS code base. |
@alsora You're welcome
At first I thought it was like that, but it seems it is only the case for publishers. I have created eProsima/Fast-DDS#434 in order for subscriber's history behavior to be consistent. |
I think that we can close this as the new FastRTPS version 1.7.1 solves the issue. |
@alsora just for your info, I do not see this fix in https://github.com/eProsima/Fast-RTPS/commits/v1.7.1. I'd re-open this as a super bug as this actually crashes the applications if you send pointclouds or images (e.g. 1MB messages). |
@ubercool2 are you seeing this crash while visualizing point clouds in rviz2 ? For ex- does rviz2 crash with segmentation fault when you subscribe to any topic publishing pointcloud2 ? |
@sagniknitr we have this problem when running https://github.com/ApexAI/performance_test. We can see that the memory usage increases (left plot, orange line) Now I've talked to @MiguelCompany offline and these are the findings:
@MiguelCompany is this correct? |
The hotfix will get cherry picked to master today, and patch release 1.7.2 will be out next week. Meanwhile, I have updated 1.7.1 release notes
A third option is to use the workaround i mention on this comment |
Fast-RTPS v1.7.2 has been released and includes eProsima/Fast-DDS#434 @alsora feel free to check the behavior is the expected. |
Issue References: * ros2/rmw_fastrtps#257 * ros2/rmw_fastrtps#258 Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>
* Update the known issues section in Crystal. Issue References: * ros2/rmw_fastrtps#257 * ros2/rmw_fastrtps#258 Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com> * remove duplicate periods
Ok, I finally tested release 1.7.2 with the current ROS2 master branch and the issue is now fixed. We can close it. |
* Update the known issues section in Crystal. Issue References: * ros2/rmw_fastrtps#257 * ros2/rmw_fastrtps#258 Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com> * remove duplicate periods
Bug report
Required Info:
Steps to reproduce issue
Define messages of fixed size
Array100kb.msg
Instantiate subscription to topic of this message type
Behavior
From what I have seen, the RAM required for instantiating a subscription, it's more or less invariant to the type of messages.
Note that I'm only running a system containing that subscriber node, no other nodes are alive.
However, testing this assumption for several values I got this
The physical memory required by the previously presented code, for a message between 50KB and 500KB it's bigger than the one required for a message of size more than 1MB.
After the peak of physical memory (56MB for a message of 450KB), the amount returns to the same constant value.
For what concerns the virtual memory usage, it keeps increasing a lot reaching 1.1GB for a message of size 4MB.
This behavior does not occur when creating publishers.
This behavior does not occur when using OpenSplice DDS.
Do you have any ideas why ?
May be related to this ? #203
Here you can find the package I used for running the tests.
https://github.com/alsora/ros2-code-examples/tree/master/simple_memory_test
It creates an executable for each data point.
I am measuring the RAM usage with
ps aux | grep sub_nodes
The package also contains a
plot.py
file where the exact results of the tests are hardcoded and you can get plot them again to better inspect the graph.The text was updated successfully, but these errors were encountered: