Proposal for C++ based ros2 topic hz
Nobody has claimed this yet.
- 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.
- Using C++ from the python topic verb will require pybind11 or ctypes, which may complicate distribution.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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