ros2 / ros2/rclcpp

Poor CPU performance with Type Adapters when using references

Open
#2,199 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

Bug report

Required Info:

  • Operating System:
    • Ubuntu Jammy 22.04
  • Installation type:
    • Source
  • Version or commit hash:
    • rclcpp 21.1.0
  • DDS implementation:
    • fastdds or cyclone
  • Client library (if applicable):
    • rclcpp
Steps to reproduce issue

It appears when publishers move + publish a Message<T> and subscription callbacks have a signature of std::function<void(const<MessageT& msg)> , the CPU load is a lot higher compared to when dealing with shared_ptr<Message<T>> or unique_ptr<Message<T>>

From my experience the CPU load for the former is almost an order of magnitude greater.
I've setup a package here with minimal reproducible code.
It appears the Intraprocess manager might not be handing moved references properly.

Expected behavior

CPU load is the same for 1 pub + 1 sub.

Actual behavior
Additional information

Feature request

Feature description
Implementation considerations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal reproducer in the linked type_adapt_example package and comparing moved Message publishing with shared_ptr<Message> and unique_ptr<Message> callbacks. Read the rclcpp Intraprocess manager path involved in these callbacks and verify that CPU load for one publisher and one subscriber is comparable across the cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.