ROS 2 on macOS: measured topic rates for each RMW, a Fast DDS shared-memory pitfall, and tuned presets
This article benchmarks ROS 2 middleware performance on macOS Apple Silicon. It identifies a ~5.7 ms polling tick in Fast DDS's default shared-memory transport caused by Boost.Interprocess fallbacks, which severely limits message rates for KEEP_LAST(1) subscribers. The author provides tuned presets for Cyclone DDS, Zenoh, and UDP-only Fast DDS to achieve clean delivery up to 100 kHz, along with specific configurations for handling large messages and avoiding common pitfalls like incorrect discovery range settings.
I run ROS 2 Jazzy and Kilted natively on macOS (Apple Silicon) through my Homebrew tap, idesign0/homebrew-ros2. In my thesis setup, a 2 kHz laser height sensor (std_msgs/Float64) arrived at only a few hundred Hz on the Mac, while the same setup gave the full 2 kHz on Linux.
I benchmarked every RMW on the Mac to find out why, how fast topics can go, and which settings get the most out of each option. Everything below can be reproduced with GitHub - idesign0/ros2-macos-rmw-bench: How fast can ROS 2 nodes talk on macOS? Inter-process rate/latency benchmark for Fast DDS, Cyclone DDS (+iceoryx), Zenoh and composition, with reproducers for macOS-specific issues. · GitHub.
TL;DR
-
Fast DDS’s default shared-memory transport (SHM) has a ~5.7 ms polling tick on macOS. Messages between processes arrive in bursts with ~3 ms median latency, at any rate. A
KEEP_LAST(1)subscriber at 2 kHz receives only ~350–450 Hz, and under heavy load delivery collapses to ~0 %. Linux is not affected. Root cause and proposed fix: [macOS] SHM transport wakes readers on a ~5.7 ms polling tick: Boost.Interprocess falls back to `spin_semaphore` on Apple · Issue #6639 · eProsima/Fast-DDS · GitHub. -
Easiest fix:
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp. Full 2 kHz at ~90 µs, clean to 50 kHz. -
Best tuned options:
Need Option Result Small messages, fast, no extra daemon Zenoh with batching off lossless to ~90 kHz at ~100 µs p99 (needs Zenoh’s router) Large messages Zenoh + SHM 4 MB at 1961 Hz (~7.8 GB/s), 0.3 ms Absolute fastest (C++ only) Cyclone + iceoryx 200 kHz at 10 µs p50 / 27 µs p99 Staying on Fast DDS FASTDDS_BUILTIN_TRANSPORTS=UDPv4clean to 20 kHz. Ignored with ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
Setup
- Hardware and OS: MacBook Pro 13" M2 (Mac14,7, 8 cores), macOS 27.0.1, Apple clang.
- ROS 2: Kilted (Fast DDS 3.2.5, Cyclone DDS 0.10.5 + iceoryx 2.0.8, rmw_zenoh) and Jazzy (Fast DDS 2.14.7), from the tap above.
- Benchmark: C++ (
rclcpp) publisher and subscriber in two separate processes, built in Release. Each message carries its send time; the subscriber measures received rate, loss, duplicates and one-way latency. - “Clean” means at least 99.9 % of messages received and p99 latency under 1 ms.
1. A 2 kHz Float64 sensor stream (subscriber KEEP_LAST(1), best effort, rclcpp::spin)
| RMW / config | Received of 2000 Hz | Latency p50 | Latency p99 |
|---|---|---|---|
| Fast DDS, default (SHM + UDP) | 354–402 Hz | 0.5–1.0 ms | 5.2–9.8 ms |
| Fast DDS, default, depth 100 | 2000 Hz | 2.9 ms | 5.6–6.3 ms |
Fast DDS, FASTDDS_BUILTIN_TRANSPORTS=UDPv4 |
1995 Hz | 82–87 µs | 172–204 µs |
| Cyclone DDS | 1998–2000 Hz | 85–97 µs | 151–163 µs |
| Cyclone DDS + iceoryx | 1998–2000 Hz | 33–36 µs | 69–71 µs |
| Zenoh | 1981–1994 Hz | 127–149 µs | 271–275 µs |
| Zenoh, batching off | 1988–2000 Hz | 150 µs | 190 µs |
On Fast DDS the rate is fine with a deep queue, but every message is ~3 ms late: samples come in bursts every ~5.7 ms, and a KEEP_LAST(1) subscriber keeps only the last one of each burst.
2. How fast can you go? (Float64, two processes, subscriber depth 100)
| RMW / config | Clean up to | p50 / p99 there | Above that |
|---|---|---|---|
| Cyclone + iceoryx (C++ only, see caveats) | 200 kHz | 10 / 27 µs | 300 kHz: 98.8 % |
| Zenoh, batching off | ~90 kHz | 53 / 97 µs | the publisher is the limit: publish() slows to ~90 kHz and nothing is lost |
| Cyclone DDS | 50 kHz | 22 / 52 µs | 100–150 kHz: no loss, but p99 7.6–32 ms |
| Zenoh, default | 20 kHz | 31 / 52 µs | 50 kHz: p99 2.1 ms (batching) |
| Fast DDS, UDPv4 only | 20 kHz | 48 / 103 µs | 50 kHz: p99 20 ms; ≥ 100 kHz: 37–51 % |
| Fast DDS, default (SHM) | never | 2.9 / 5.7 ms at every rate | ≥ 100 kHz: 0–1.5 % received, seconds of latency |
| Same process (composition, intra-process) | 100 kHz | 3 / 19 µs (Cyclone) | 200 kHz: 98.9 % |
3. Large messages (two processes, 2 kHz offered, p50 latency)
| RMW / config | 256 KB | 1 MB | 4 MB |
|---|---|---|---|
| Zenoh + SHM | 1999 Hz, 78 µs | 1999 Hz, 128 µs | 1961 Hz, 296 µs |
| Zenoh | 2000 Hz, 173 µs | 2000 Hz, 399 µs | 869 Hz, 1.5 ms |
| Cyclone + iceoryx | 1912 Hz, 32 µs | 1982 Hz, 100 µs | publisher hangs with default RouDi pools; 2001 Hz, 341 µs with bigger pools |
| Cyclone DDS | 1989 Hz, 357 µs | 1964 Hz, 554 µs | 16 Hz |
| Fast DDS, UDPv4 only | 1994 Hz, 154 µs | 1780 Hz, 429 µs | 0 received |
4. Why Fast DDS SHM behaves like this on macOS
Fast DDS waits for SHM data on an interprocess semaphore from its bundled Boost.Interprocess. On macOS, Boost disables the native process-shared primitives (Darwin’s pthread_cond is not truly process-shared, and sem_init returns ENOSYS), so it falls back to a spin semaphore. After a short spin, that semaphore sleeps for half a system tick: sysconf(_SC_CLK_TCK) = 100, so nanosleep(5 ms), ≈ 6 ms in practice.
Shortening that one sleep (an injected nanosleep shim) made the problem disappear, which confirms the cause, but at a CPU cost. A proper fix with macOS 14.4’s os_sync_wait_on_address woke a second process in 6–10 µs in my prototype. Full analysis: [macOS] SHM transport wakes readers on a ~5.7 ms polling tick: Boost.Interprocess falls back to `spin_semaphore` on Apple · Issue #6639 · eProsima/Fast-DDS · GitHub.
Presets: best settings for each option
A. Cyclone DDS: simplest, recommended default
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
- No daemon. 2 kHz at ~90 µs; clean to 50 kHz, lossless to ~150 kHz with a growing p99.
- Tuning: socket buffers,
MaxMessageSizeandFragmentSizemade no meaningful difference. The defaults are already its best. - Gotcha: if your
CYCLONEDDS_URIsets<ParticipantIndex>none</ParticipantIndex>(a common tip for many nodes), don’t also setROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST. In my test that combination found no peers. - Avoid for very large messages: 4 MB arrived at only 16 Hz. Use Zenoh + SHM or iceoryx for those.
B. Zenoh: tuned, best all-rounder for high rates
ros2 run rmw_zenoh_cpp rmw_zenohd & # router, once per machine
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
export ZENOH_CONFIG_OVERRIDE='transport/link/tx/queue/batching/enabled=false'
# large messages: also enable shared memory (only used for messages > 512 B)
export ZENOH_CONFIG_OVERRIDE='transport/link/tx/queue/batching/enabled=false;transport/shared_memory/enabled=true'
- Batching off is the important knob. At 50 kHz it cuts p99 from 2.1 ms to 65–112 µs. With it, Zenoh is lossless up to the ~90 kHz the publisher can sustain, and it applies back-pressure instead of dropping.
- SHM on is the best large-message option I measured: 4 MB at 1961 Hz.
- Not helpful:
transport/unicast/lowlatency=truemade the tail worse (p99 6–8 ms).
C. Fast DDS: if you have to stay on it
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTDDS_BUILTIN_TRANSPORTS=UDPv4
# do NOT set ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST
- Removes the 5.7 ms tick: 2 kHz at ~85 µs; clean to 20 kHz.
- Gotcha: with
ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST,rmw_fastrtpssets up its own SHM + UDP transports (rmw_fastrtps_shared_cpp/src/participant.cpp, Jazzy and Kilted). The variable is then ignored, and I measured the same ~330 Hz / 5 ms behaviour. - Tuning: a UDP-only XML profile with 4 MB socket buffers performed the same as the variable.
- Avoid:
RMW_FASTRTPS_PUBLICATION_MODE=ASYNCHRONOUS:publish()threwcannot publish dataat 5 kHz and aborted the publisher;- 4 MB messages: none arrived.
D. Cyclone DDS + iceoryx: fastest between processes (C++ only)
Both the Jazzy and Kilted kegs ship Cyclone built with iceoryx, plus iox-roudi and iox-introspection-client. Config files: ros2-macos-rmw-bench/config at main · idesign0/ros2-macos-rmw-bench · GitHub
- Start RouDi, the iceoryx daemon. Run one per machine, before or together with your nodes; nodes that start first wait for it.
iox-roudi # default pools: chunks up to 4 MB iox-roudi -c roudi_config_large.toml # adds 8 MB chunks, for messages >= ~4 MB - Enable shared memory in Cyclone:
Or merge theexport RMW_IMPLEMENTATION=rmw_cyclonedds_cpp export CYCLONEDDS_URI='<CycloneDDS><Domain><SharedMemory><Enable>true</Enable></SharedMemory></Domain></CycloneDDS>'<SharedMemory>block into the Cyclone XML you already use. - In a launch file, add
ExecuteProcess(cmd=['iox-roudi'])and set both environment variables withSetEnvironmentVariable. There’s a working example in the repo. - Verify it’s used: latency is the clearest sign, ~10 µs instead of ~70–90 µs over UDP.
iox-introspection-client --portlists the ports.
Results: 2 kHz at ~35 µs; 200 kHz at 10 / 27 µs; 1 MB messages at 1982 Hz, 100 µs.
Rules (from rmw_cyclonedds’ shared memory doc and my measurements):
- Types: zero-copy only for fixed-size message types: no strings, no sequences, so nothing with a
Header. Other types are serialized into shared memory, a smaller gain. - QoS: KEEP_LAST history; reliable and best effort both work. The doc says publisher depth ≤ 16; this build still used shared memory at 17 and 100, but keep ≤ 16 to be safe.
- Limits: one RouDi per machine; at most 127 subscriptions per process.
- Memory pool: if no chunk fits,
publish()blocks forever. A 4 MB message with the default pools hung my publisher. - No RouDi: every node waits for it and aborts after ~60 s.
Bugs I hit (Kilted, Cyclone 0.10.5), reported in Issues · ros2/rmw_cyclonedds · GitHub
- Duplicates between C++ and Python: when one endpoint is
rclcppand the otherrclpy, every message is delivered twice, in both directions. C++ ↔ C++ and Python ↔ Python are fine; every C++ number above was checked for duplicates. - QoS check bypassed: a reliable subscriber receives data from a best-effort publisher over shared memory, even though ROS logs the QoS as incompatible.
- Consequence:
ros2 topic hzshows 2× the real rate. - Known upstream:
transient_localover SHM (ros2/rmw_cyclonedds#401).
E. Composition: fastest with no daemon at all
Load publisher and subscriber as components into one component_container, with use_intra_process_comms: true. Messages never leave the process: 100 kHz at 3 / 19 µs on Cyclone. This works with any RMW.
F. For every option
- Queue depth: with bursty delivery (Fast DDS SHM, USB-serial sensors),
KEEP_LAST(1)/SensorDataQoSsilently drops most messages. If every sample matters, use a deeper queue, for examplerclcpp::QoS(50).best_effort(). - USB-serial sensors: macOS has no equivalent of the Linux udev
latency_timer=1rule for FTDI adapters. Data arrives in ~16 ms batches regardless of RMW. - Executor: the rclcpp EventsExecutor was within 5–10 % of the default at 2 kHz, so it’s not worth switching for this.
- Background load: Spotlight indexing or builds cause occasional 0.1–0.4 s stalls on every transport at high rates.
- Build in Release when you benchmark. An unoptimized build of my own benchmark cut large-message throughput ~3.5×.
Method and caveats
- Same machine, Release build. Each point is a 4 s window after 1.5 s of discovery; ranges are over repeated runs, measured on a quiet machine.
- The rate sweep’s subscriber busy-spins; a normal
rclcpp::spin()node will be a little lower. - Linux was not measured on the same hardware, so I can’t give a side-by-side comparison.
- Reproduce:
scripts/full_sweep.shin GitHub - idesign0/ros2-macos-rmw-bench: How fast can ROS 2 nodes talk on macOS? Inter-process rate/latency benchmark for Fast DDS, Cyclone DDS (+iceoryx), Zenoh and composition, with reproducers for macOS-specific issues. · GitHub runs everything above; RESULTS.md has every number.
Feedback welcome, especially from anyone who sees different numbers on Intel Macs or other macOS versions.