-
Notifications
You must be signed in to change notification settings - Fork 453
deprecate rclcpp::spin_some and rclcpp::spin_all #2848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rolling
Are you sure you want to change the base?
Conversation
4bf1cb8
to
e8e8faf
Compare
…match the other executors Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
e8e8faf
to
f1e7310
Compare
#else // !defined(_WIN32) | ||
# pragma warning(push) | ||
# pragma warning(disable: 4996) | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a macro for this in cpputils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is ros2/rcpputils#210
#else // !defined(_WIN32) | ||
# pragma warning(push) | ||
# pragma warning(disable: 4996) | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is ros2/rcpputils#210
|
||
auto request = std::make_shared<test_msgs::srv::Empty::Request>(); | ||
auto future = empty_client->async_send_request(request); | ||
state.ResumeTiming(); | ||
benchmark::DoNotOptimize(service); | ||
benchmark::ClobberMemory(); | ||
|
||
rclcpp::spin_until_future_complete(node->get_node_base_interface(), future); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need deprecate this too?
Description
Deprecate
rclcpp::spin_some
andrclcpp::spin_all
.These functions can lead to very poor performance for developers who are not aware that calling them will:
If called in a loop, you are wasting a lot of CPU cycles repeating those operations every time.
This instead is a lot more efficient because only the spin operation is repeated as expected.
Adding and removing nodes from executors are expensive operations that shouldn't be done at "steady state" of the system.
IMPORTANT
In this PR I'm also re-ordering the events-executor constructor arguments so that this becomes possible:
Now all executors take the executor options as first argument.
Is this user-facing behavior change?
Yes, deprecating some functions and modifying a constructor (although it's in the experimental namespace)
Did you use Generative AI?
No
closes #2675