Skip to content

Commit c32890c

Browse files
Janosch MachowinskiJanosch Machowinski
authored andcommitted
feat: Added new CBGExecutor
Signed-off-by: Janosch Machowinski <[email protected]>
1 parent 36e692a commit c32890c

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

rclcpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ set(${PROJECT_NAME}_SRCS
6262
src/rclcpp/executable_list.cpp
6363
src/rclcpp/executor.cpp
6464
src/rclcpp/executors.cpp
65+
src/rclcpp/executors/cbg_executor.cpp
6566
src/rclcpp/executors/executor_entities_collection.cpp
6667
src/rclcpp/executors/executor_entities_collector.cpp
6768
src/rclcpp/executors/executor_notify_waitable.cpp

rclcpp/test/benchmark/benchmark_executor.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "performance_test_fixture/performance_test_fixture.hpp"
2121

2222
#include "rclcpp/rclcpp.hpp"
23+
#include "rclcpp/executors/cbg_executor.hpp"
2324
#include "rcpputils/scope_exit.hpp"
2425
#include "test_msgs/msg/empty.hpp"
2526

@@ -145,6 +146,12 @@ BENCHMARK_F(PerformanceTestExecutor, multi_thread_executor_spin_some)(benchmark:
145146
executor_spin_some<rclcpp::executors::MultiThreadedExecutor>(st);
146147
}
147148

149+
BENCHMARK_F(PerformanceTestExecutor, cbg_executor_spin_some)(benchmark::State & st)
150+
{
151+
executor_spin_some<rclcpp::executors::CBGExecutor>(st);
152+
}
153+
154+
148155
BENCHMARK_F(PerformanceTestExecutor, single_thread_executor_wait_for_work)(benchmark::State & st)
149156
{
150157
benchmark_wait_for_work<rclcpp::executors::SingleThreadedExecutor>(st);
@@ -155,6 +162,11 @@ BENCHMARK_F(PerformanceTestExecutor, multi_thread_executor_wait_for_work)(benchm
155162
benchmark_wait_for_work<rclcpp::executors::MultiThreadedExecutor>(st);
156163
}
157164

165+
BENCHMARK_F(PerformanceTestExecutor, cbg_executor_wait_for_work)(benchmark::State & st)
166+
{
167+
benchmark_wait_for_work<rclcpp::executors::CBGExecutor>(st);
168+
}
169+
158170
class CascadedPerformanceTestExecutor : public PerformanceTest
159171
{
160172
public:
@@ -238,11 +250,16 @@ BENCHMARK_F(CascadedPerformanceTestExecutor, multi_thread_executor_spin_some)(be
238250
executor_spin_some<rclcpp::executors::MultiThreadedExecutor>(st);
239251
}
240252

253+
BENCHMARK_F(CascadedPerformanceTestExecutor, cbg_executor_spin_some)(benchmark::State & st)
254+
{
255+
executor_spin_some<rclcpp::executors::CBGExecutor>(st);
256+
}
241257

242258

243259
class PerformanceTestExecutorMultipleCallbackGroups : public PerformanceTest
244260
{
245261
public:
262+
// static constexpr unsigned int kNumberOfNodes = 20;
246263

247264
void SetUp(benchmark::State & st)
248265
{
@@ -336,6 +353,12 @@ BENCHMARK_F(
336353
{
337354
executor_spin_some<rclcpp::executors::MultiThreadedExecutor>(st);
338355
}
356+
357+
BENCHMARK_F(
358+
PerformanceTestExecutorMultipleCallbackGroups,
359+
cbg_executor_spin_some)(benchmark::State & st)
360+
{
361+
executor_spin_some<rclcpp::executors::CBGExecutor>(st);
339362
}
340363

341364
class PerformanceTestExecutorSimple : public PerformanceTest
@@ -465,6 +488,16 @@ BENCHMARK_F(PerformanceTestExecutorSimple, multi_thread_executor_remove_node)(be
465488
remove_node<rclcpp::executors::MultiThreadedExecutor>(st);
466489
}
467490

491+
BENCHMARK_F(PerformanceTestExecutorSimple, cbg_executor_add_node)(benchmark::State & st)
492+
{
493+
add_node<rclcpp::executors::CBGExecutor>(st);
494+
}
495+
496+
BENCHMARK_F(PerformanceTestExecutorSimple, cbg_executor_remove_node)(benchmark::State & st)
497+
{
498+
remove_node<rclcpp::executors::CBGExecutor>(st);
499+
}
500+
468501
BENCHMARK_F(
469502
PerformanceTestExecutorSimple,
470503
static_single_thread_executor_add_node)(benchmark::State & st)
@@ -493,6 +526,13 @@ BENCHMARK_F(
493526
spin_node_until_future_complete<rclcpp::executors::MultiThreadedExecutor>(st);
494527
}
495528

529+
BENCHMARK_F(
530+
PerformanceTestExecutorSimple,
531+
cbg_executor_spin_node_until_future_complete)(benchmark::State & st)
532+
{
533+
spin_node_until_future_complete<rclcpp::executors::CBGExecutor>(st);
534+
}
535+
496536
BENCHMARK_F(
497537
PerformanceTestExecutorSimple,
498538
static_single_thread_executor_spin_node_until_future_complete)(benchmark::State & st)

rclcpp/test/rclcpp/executors/test_executors.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "rclcpp/duration.hpp"
3737
#include "rclcpp/guard_condition.hpp"
3838
#include "rclcpp/rclcpp.hpp"
39+
#include "rclcpp/executors/cbg_executor.hpp"
3940

4041
#include "test_msgs/msg/empty.hpp"
4142

@@ -89,6 +90,7 @@ using ExecutorTypes =
8990
rclcpp::executors::SingleThreadedExecutor,
9091
rclcpp::executors::MultiThreadedExecutor,
9192
rclcpp::executors::StaticSingleThreadedExecutor,
93+
rclcpp::executors::CBGExecutor,
9294
rclcpp::experimental::executors::EventsExecutor>;
9395

9496
class ExecutorTypeNames
@@ -110,6 +112,10 @@ class ExecutorTypeNames
110112
return "StaticSingleThreadedExecutor";
111113
}
112114

115+
if (std::is_same<T, rclcpp::executors::CBGExecutor>()) {
116+
return "CallbackGroupExecutor";
117+
}
118+
113119
if (std::is_same<T, rclcpp::experimental::executors::EventsExecutor>()) {
114120
return "EventsExecutor";
115121
}
@@ -128,6 +134,7 @@ using StandardExecutors =
128134
::testing::Types<
129135
rclcpp::executors::SingleThreadedExecutor,
130136
rclcpp::executors::MultiThreadedExecutor,
137+
rclcpp::executors::CBGExecutor,
131138
rclcpp::experimental::executors::EventsExecutor>;
132139
TYPED_TEST_SUITE(TestExecutorsStable, StandardExecutors, ExecutorTypeNames);
133140

0 commit comments

Comments
 (0)