Message Flow Analysis with Complex Causal Links for Distributed ROS 2 Systems

Christophe Bédard, Pierre-Yves Lajoie, Giovanni Beltrame, Michel R. Dagenais · DOI

Introduction

In modern robotics, the Robot Operating System 2 (ROS 2) has become a standard for modular software development. By utilizing a publish-subscribe model, ROS 2 allows developers to build complex systems where data moves between independent "nodes." However, as these systems grow and are distributed across multiple physical machines, understanding the end-to-end performance becomes increasingly difficult. The ROS 2 executor—responsible for scheduling and running tasks—often becomes a hidden performance bottleneck.

Researchers from Polytechnique Montréal have introduced a novel extension to the ros2_tracing framework designed to track message flows across distributed systems. Their approach identifies complex one-to-many and many-to-many causal links with minimal overhead, providing developers with the visibility needed to optimize latency-sensitive robotic applications.

The Challenge of Distributed Tracing

Answering a fundamental question like "How long did it take for this specific camera frame to result in a motor command?" is surprisingly complex in ROS 2. Existing performance tools often suffer from high overhead, require extensive code modifications, or fail to account for non-linear logic where a node might buffer multiple inputs before producing an output. This research addresses these gaps by stitching together message paths across different processes and physical machines without significantly impacting system performance.

Methodology: Tracking the Data Flow

The researchers' solution is built upon three primary pillars designed to provide a transparent view of the system's internal state.

1. Intermediate Execution Representation (IER)

The system utilizes a specialized database to store trace data. To solve the "identity crisis" inherent in distributed systems, the researchers implemented a unique 3-tuple identifier for tracking objects: the memory address (pointer), the Process ID (PID), and a unique Host ID. This allows the framework to uniquely identify messages as they traverse the network without needing to inject global IDs into every message header.

Visualization of message flow across distributed hosts in Trace Compass.

To connect a message published on one machine to its reception on another, the framework uses metadata such as source timestamps and topic names. Causal links are then established through two methods:

  • Direct Links: Automatically identified when a message is published during a callback triggered by a specific input.
  • Indirect Links: For complex logic (e.g., averaging a buffer of five messages), the authors introduced a simple macro annotation. This allows developers to provide a "hint" to the tracing framework regarding internal causal relationships.

Visualization and Performance Analysis

The framework integrates these flows into Trace Compass, an open-source tool that provides a Gantt-chart-style view of message hops and executor states. This visualization is critical for distinguishing between time spent in computation versus time spent waiting for CPU resources.

Gantt-style visualization of message flows and executor states in the Autoware Reference System.

Experimental Results

The methodology was validated using two distinct environments: the Autoware Reference System (a synthetic autonomous driving benchmark) and RTAB-Map SLAM (a real-world mapping system distributed across an NVIDIA Jetson and a laptop).

  • Negligible Overhead: In a 10Hz test system, the mean end-to-end latency increased by only 0.1597 ms, making it suitable for production-grade systems.
  • Optimization Insights: Using the tool on the Autoware system, the researchers demonstrated that switching to a multi-threaded executor reduced end-to-end latency from 370 ms to 298 ms. The visualization clearly quantified the gains from concurrent sensor data processing.
  • Distributed Success: The team successfully mapped a SLAM pipeline across a wireless network, identifying the exact breakdown between transport latency and processing time.

Conclusion and Future Work

This research provides a robust, low-overhead method for analyzing message flows in complex ROS 2 environments. While the current system requires some manual annotation for indirect links, it offers unprecedented visibility into executor bottlenecks. Future work aims to automate causal link detection further and implement "critical path analysis" to automatically identify the sequence of tasks most responsible for system-wide latency.

Source Code: github.com/christophebedard/ros2-message-flow-analysis

Summary updated

BibTeX
@article{bedard2022message,
  author = {Christophe Bédard and Pierre-Yves Lajoie and Giovanni Beltrame and Michel R. Dagenais},
  title = {{Message Flow Analysis with Complex Causal Links for Distributed ROS 2 Systems}},
  journal = {Robotics Auton. Syst.},
  year = {2022},
  doi = {10.1016/j.robot.2022.104361},
}
Figure