ros2 / ros2/ros2cli

Proposal for C++ based ros2 topic hz

Open
#1,043 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
Python
Stars
262
Forks
228
Avg merge
23h 15m
Merged PRs (30d)
12

Description

Hello, I am considering putting together an MR to contribute a more performant C++ implementation of ros2 topic hz (and maybe ros2 topic bw while we are at it).

I think even with #1005 merged, performance of ros2 topic hz remains poor, especially for high frequency topics. I think #843 is still an issue. I did some informal experiments awhile ago to confirm this, which I can replicate and share if desired (did anyone else run experiments on this btw? would be good to compare notes)

When I switch to a C++ based implementation I see a ~8x reduction in CPU usage, and can accurately report topic frequencies up to 10Khz, whereas the existing ros2 topic hz caps out around a 2-3khz.

There are two caveats to this that I see already.

  1. Using C++ from the python topic verb will require pybind11 or ctypes, which may complicate distribution.
  2. the --filter option accepts arbitrary python code, so likely we would want to fallback to the original hz.py implementation just for --filter, which is a little ugly.

I'd like to get the maintainers thoughts on this, would this MR be something you are interested in merging? Are there other gotchas I am not considering?

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 with ros2topic/ros2topic/command/topic.py and the existing hz.py implementation, then reproduce the reported high-frequency performance measurements. Clarify the maintainer-approved design for the C++ integration, distribution approach, and --filter fallback; done would mean an accepted implementation with comparable performance evidence and coverage for the affected commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
cli, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.