Is ros2 topic hz accurate at 1 kHz? hz and bw vs a C++ message counter, measured up to 10 kHz

Is ros2 topic hz accurate at 1 kHz? hz and bw vs a C++ message counter, measured up to 10 kHz

Short answer: ros2 topic hz was accurate at the rates most robots use. At 400 Hz and 1,000 Hz it matched a C++ subscriber counting every message to within 0.2% on Humble and Jazzy. It only fell behind at very high rates. On a 2-vCPU machine it topped out around 4,600–5,000 Hz, so a 10 kHz topic was reported at about half its real rate. ros2 topic bw averages only the last 100 messages and counts a little more than the serialized message size, so don’t use it to work out a rate. If hz shows 750 Hz at 1 kHz, check whether the publisher really reaches 1 kHz before you blame the tool.

Is ros2 topic hz accurate at 1 kHz? hz and bw vs a C++ message counter, measured up to 10 kHz — measured results table
At a glance: the main measured table from this article. Full details below.

What I ran

On 2026-10-27 I built two small C++ nodes in the official ros:humble-ros-base and ros:jazzy-ros-base Docker images, on a 2-vCPU Intel Xeon Platinum 8259CL host. The publisher sends a sensor_msgs/JointState with two joints (108 bytes serialized, like a small /joint_states) from a wall timer at a set rate. The counter subscribes with a queue depth of 1000, waits 2 s, then counts messages and bytes for 10 s. For each rate I ran the counter, then ros2 topic hz for 14 s, then ros2 topic bw for 14 s, one at a time so they didn’t compete for CPU.

ros2 topic hz matches a C++ counter up to 5000 Hz, then flattens near 4600 to 5000 Hz while the C++ counter keeps rising
Up to 5,000 Hz the lines overlap. At 10,000 Hz, hz reports about half of what the C++ subscriber received.
Target Humble: counted / hz Jazzy: counted / hz
400 Hz 400.0 / 400.0 400.0 / 400.0
1,000 Hz 1,000.0 / 999.9 999.8 / 1,000.0
2,000 Hz 1,780.4 / 1,999.4 1,997.7 / 2,000.4
5,000 Hz 4,499.8 / 4,992.5 4,986.6 / 4,985.0
10,000 Hz 8,861.6 / 4,948.4 6,918.6 / 4,568.7

Up to 5,000 Hz, hz agreed with the publisher’s target. In two Humble runs (2,000 and 5,000 Hz), my C++ counter received fewer messages than hz reported. A busy subscriber can fall behind too, so the counter isn’t a perfect reference either. At 10,000 Hz the two diverge in the other direction. The C++ counter received 6,900–8,900 messages per second, while hz stayed below 5,000.

Why ros2 topic bw doesn’t line up

Target Counted (serialized bytes) ros2 topic bw
400 Hz 42.2 KB/s 43.3–43.5 KB/s
1,000 Hz 105.5 KB/s 108.1–108.8 KB/s
5,000 Hz 474.6–525.9 KB/s 540.4–540.7 KB/s
10,000 Hz 729.7–934.6 KB/s 535.4–575.5 KB/s

Every bw line ends with from 100 messages. It averages a window of the latest 100 messages, which at 1 kHz is a tenth of a second. Where my counter kept up with the publisher (both distros at 400 and 1,000 Hz, Jazzy at 2 and 5 kHz), it read about 3% higher than the serialized size my counter summed. At 10 kHz it fell behind just like hz. So rate × message size from hz won’t match bw exactly even when both work. Treat bw as a rough bandwidth figure, not a second rate meter.

What this means for the 1 kHz controller case

The question this answers saw about 750 Hz from hz with the controller manager set to 1 kHz, on a Raspberry Pi 4. In my test, hz measured a real 1 kHz topic correctly. That was on faster x86 cores, and I didn’t test a Pi 4. So before trusting the tool’s limits, check how many messages actually arrive. A small counting subscriber like mine (in the evidence folder) takes a minute to build. If it also shows about 750 Hz, the publisher isn’t keeping up with 1 kHz. If it shows 1,000, hz is the bottleneck on that machine.

Run hz and bw one at a time, and not on the machine that is already at full load. Each one is a Python process that receives every message.

Not explained

With ros2 topic hz -w 2000 (a larger averaging window), Jazzy printed 394.1 Hz at 400 Hz and 963.9 Hz at 1,000 Hz. The default window gave 400.0 and 1,000.0 in the same runs. Humble didn’t show this. I didn’t track down why.

FAQ

Is ros2 topic hz accurate?

At 400 Hz and 1,000 Hz it matched a C++ subscriber counting every message to within 0.2% on Humble and Jazzy. It only fell behind at very high rates.

What is the highest rate ros2 topic hz can measure?

On a 2-vCPU machine it topped out around 4,600–5,000 Hz. A 10 kHz topic was reported at about half its real rate.

Why don’t ros2 topic hz and ros2 topic bw line up?

bw averages only the latest 100 messages and read about 3% higher than the serialized size my counter summed. So rate times message size from hz won’t match bw exactly, even when both work.

ros2 topic hz shows 750 Hz for a 1 kHz topic. Is the tool wrong?

In my test hz measured a real 1 kHz topic correctly, on x86 cores, and I didn’t test a Raspberry Pi 4. Count the messages that actually arrive with a small subscriber. If it also shows about 750 Hz, the publisher isn’t keeping up.

Can I run ros2 topic hz and bw at the same time?

Run them one at a time, and not on a machine that is already at full load. Each one is a Python process that receives every message.

Not tested

Raspberry Pi or other ARM boards, Lyrical, Cyclone DDS (all runs used the default Fast DDS), larger messages such as images, and running hz on a different machine from the publisher.

Source, scripts and raw output: evidence folder. Question this answers: Inconsistency between ros2 topic hz and bw. Related: rclpy publish slow with large custom message arrays.