Replace the rosbag2_py recorder executor with the EventsCBGExecutor - #2472
Conversation
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
rosbag2_py recorder executor with the EventsCBGExecutor
|
Update: per @jmachowinski 's suggestion, I made a slight modification to
When each message arrives staggered vs at the same time, the |
|
Tick the box to add this pull request to the merge queue (same as
|
|
Pulls: #2472 |
|
I wonder if we should guard this with a parameter. |
|
Pulls: #2472 |
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm, i mean why not?
one minor comment is applying the same executor change to the Player? i understand the Recorder is the critical path, but any downside to apply EGB Executor to the Player as well?
|
I don't think there'd be any downsides, we just wouldn't have as dramatic of performance improvement we're seeing here with the recorder since that node's only responsible for a handful of services. Happy to add it to this PR or follow up with another one, since we want to move in the direction of events based executors being the default anyway |

Description
This PR swaps the
SingleThreadedExecutorused in therosbag2_pyrecorderclass with theEventsCBGExecutor, resulting in on average 15 - 23% less CPU with the existing benchmark (each publisher publishing at the same time in a loop), and up to 43% less CPU with staggered publishing.This PR also adds a few more benchmark configs to
rosbag2_performance_benchmarkingwhich are more focused on benchmarking the message rate rather than bandwidth / IO.See more extensive benchmarks below in Additional Information
Follow-up to the discussion in #743
Is this user-facing behavior change?
Not really. Functionality is preserved, but with less CPU usage
Did you use Generative AI?
Claude Opus 5 was used to generate the benchmarking harnesses and new topologies, with a lot of paring down by me.
Additional Information
All benchmarks were done on my x86 lenovo developer laptop.
FastDDS was used for all these runs. Note, that at 1000hz, I was able to reproduce the already documented deadlock issues that this PR addresses. All runs were done with this PR cherry-picked into my workspace.
All CPU values are expressed as % of a core.
Pre-existing rosbag benchmarks (3 runs each):
many_small saturation ladder (20 runs each):
CPU Usage by Thread was also inferred (according to the thread name and usage) across these runs, by sampling every thread under
/proc/<pid>/taskevery 0.5 seconds.The effects on latency were benchmarked by computing the
recv_timestamp-send_timestampin a utility script. In exchange for lower CPU, it's worth noting there is around a ~30 microsecond per message increase in latency, on average.As a footnote, the use of multiple recording threads was experimented with, but this only increased the CPU usage without any real benefits to latency at any message publication frequency. Therefore, this PR simply replaces a single-threaded wait set executor with a single threaded events queue based one.