Proposal for C++ based ros2 topic hz

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

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.

Description

help wanted

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?

Dominant language
Python
Stars
274
Forks
246
Avg merge
1d 14h
Merged PRs (30d)
12

Getting set up

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.

More from ros2/ros2cli

All issues in ros2/ros2cli

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.