ros2 / rmw_fastrtps

Implementation of the ROS Middleware (rmw) Interface using eProsima's Fast RTPS.
Apache License 2.0
155 stars 117 forks source link

High latency on multi-process simple pub/sub with `DYNAMIC_REUSABLE` #782

Open mauropasse opened 1 day ago

mauropasse commented 1 day ago

On rolling, I'm seeing high latency when using DYNAMIC_REUSABLE as history memory policy & zero copy. In the other hand, latency seems OK when using PREALLOCATED_WITH_REALLOC. Also latency seems OK when the system is single-process, regardless of the policy (still using loaned msgs).

The system tested uses shared memory to pass a 4MB loaned message between processes:

Multi-process system:
- Process 1: Publisher of 4Mb Loaned messages (10Hz)
- Process 2: Subscription of 4Mb messages
- Platforms: x86 & RaspberryPi4

As reference I'm also showing latency of IPC OFF, i.e. not using Loaned messages with shared memory (normal serialized msg).

Below I provide a CPU flamegraph (from RPi) for both policies:

The XML config file looks like this for both reader & writer:

  <qos><data_sharing><kind>AUTOMATIC</kind></data_sharing></qos>
  <historyMemoryPolicy>DYNAMIC_REUSABLE</historyMemoryPolicy>
  <!-- other: PREALLOCATED_WITH_REALLOC -->

Since in this case we're aiming for zero-copy using shared memory with loaned messages, I'm guessing this copy is undesired, i.e. a bug? What do you think?

MiguelCompany commented 13 hours ago

One of the data-sharing constraints is that the memory policy of the DataWriter should be either PREALLOCATED_MEMORY_MODE or PREALLOCATED_WITH_REALLOC_MEMORY_MODE

This means data-sharing delivery is not used with DYNAMIC_REUSABLE