Skip to content

topic delay performance overhead #1214

@DanBmh

Description

@DanBmh

When trying to measure the topic delay of camera images for a real time setup, I found that ros2 topic delay is not very well suited for this:

  • too few digits and metrics to measure millisecond delays
  • using python to calculate the delay introduces a notable overhead

This can be well seen if comparing it against a custom c++ tooling i've created for those reasons:

ros2 topic delay /camera02/pylon_ros2_camera_node/image_raw 
average delay: 0.014 	min: 0.014s max: 0.015s std dev: 0.00016s window: 131
average delay: 0.014	min: 0.014s max: 0.015s std dev: 0.00015s window: 181
average delay: 0.014	min: 0.014s max: 0.015s std dev: 0.00015s window: 231
average delay: 0.014	min: 0.014s max: 0.015s std dev: 0.00014s window: 281
average delay: 0.014	min: 0.014s max: 0.015s std dev: 0.00014s window: 331
ros2 run micro_delay micro_delay --ros-args -p topic:=/camera02/pylon_ros2_camera_node/image_raw
Avg: 0.012300s | Min: 0.012173s | P5: 0.012185s | P50: 0.012308s | P95: 0.012422s | Max: 0.012436s
Avg: 0.012321s | Min: 0.012186s | P5: 0.012194s | P50: 0.012323s | P95: 0.012513s | Max: 0.012531s
Avg: 0.012347s | Min: 0.012180s | P5: 0.012197s | P50: 0.012352s | P95: 0.012506s | Max: 0.012522s
Avg: 0.012358s | Min: 0.012172s | P5: 0.012194s | P50: 0.012374s | P95: 0.012473s | Max: 0.012477s
Avg: 0.012375s | Min: 0.012251s | P5: 0.012266s | P50: 0.012403s | P95: 0.012460s | Max: 0.012463s

The delay measured by my custom c++ tool is around 2ms less than the one reported by ros2 topic delay. I assume the main difference is caused by the better optimized programming language.

One important advantage of the python implementation here is that it works with arbitrary topics, while my c++ version only with sensor_msgs::msg::Image. So I can't provide an adequate replacement, but only inform about this possible performance problem.

The code for the micro_delay tool can be found here: https://gitlab.com/Percipiote/CamStreamer/-/blob/master/extras/delay/micro_delay/src/micro_delay.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions