-
Notifications
You must be signed in to change notification settings - Fork 422
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
add events-executor and timers-manager in rclcpp #2155
Conversation
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 think that most (all?) of the tests here can probably moved to the test_executors.cpp
file as they are valid tests for all executors.
rclcpp/include/rclcpp/experimental/executors/events_executor/events_executor.hpp
Outdated
Show resolved
Hide resolved
rclcpp/include/rclcpp/experimental/executors/events_executor/events_executor_event_types.hpp
Outdated
Show resolved
Hide resolved
private: | ||
// The underlying queue implementation | ||
std::queue<rclcpp::experimental::executors::ExecutorEvent> event_queue_; | ||
// Mutex to protect the insertion/extraction of events in the queue |
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.
Is not just insertion/extraction, is also checking size and if empty:
// Mutex to protect the insertion/extraction of events in the queue | |
// Mutex to protect concurrent actions over the queue |
// The second argument of the callback should identify which guard condition | ||
// triggered the event. | ||
// We could indicate which of the guard conditions was triggered, but the executor | ||
// is already going to check that. |
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.
Actually the executor doesn't check which guard condition was triggered, it just knows the waitable to whom it belongs.
If the executor knows which gc
was triggered, it could more efficiently do work on the node or entity having this gc
.
For example right know, a single gc
triggered due addition of an entity to a node, will result on re-setting the callbacks to all nodes entities registered in the executor. We could use this info to get only the node having this gc
and setting the callbacks to it. This is just a peformance improvement, but we already have the notify_waitable_event_pushed_
which is mitigating this issue.
Also if we manage to add apis to not notify the executor for every entity added, until manually done later, this will be less a problem
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.
Few comments here:
- Yes, the executor doesn't check which guard condition triggered, but we could easily do that (maybe I should change the
should
intocould
in the comment) - This new implementation does not re-set the callbacks to all the nodes. It performs a loop on all the entities to understand which ones have been added/removed and then it does only the necessary work. By taking into account the possible improvement mentioned in (1) we could speed up the loop (i.e. loop only on one node, rather than on all nodes), but the set/unset would remain equivalent.
IMO, the fact that we don't reset everything, plus the presence of the notify_waitable_event_pushed_
flag, should already improve the resource usage during startup.
Controlling the notification to the executor would still be important to reduce the amount of time we loop over the entities.
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.
Also if we manage to add apis to not notify the executor for every entity added, until manually done later, this will be less a problem
While we can't get this for Iron, I would like to get it in sooner rather than later in rolling while we all still have context.
rclcpp/src/rclcpp/experimental/executors/events_executor/events_executor.cpp
Outdated
Show resolved
Hide resolved
0816eaf
to
be41ece
Compare
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
…ks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
91337dc
to
4ec0b9d
Compare
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.
lgtm
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.
This looks good to me. I'm going to run CI on this again since there have been host of changes since the last one. I'll also run Windows Debug and RHEL.
All right, everything is green here so going ahead and merging. Thanks everyone for the reviews and work. |
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
Any plans to backport this to Humble or is it too complex to do so? |
We don't currently have plans to do it. The implementation of the events-executor that got merged in this PR is slightly different from what is in the old repo. If all the prerequisites are there already, it should be possible to backport without touching existing files, and I would be more than happy to review the PRs. |
Would it be possible to get this into iron? Or is that something not done with non-LTS releases? Seems unfortunate to have to wait till next ROS2 release for this. |
This is currently in Iron. |
Ah great. I must have missed it in the release notes. |
I think it's not in the release notes, at least it wasn't 5 days ago when I looked. It would be useful to add! (+ How to make the switch) |
@mjcarroll is adding it in ros2/ros2_documentation#3662 |
* add events-executor and timers-manager in rclcpp fix check for execute_timers_separate_thread; ignore on_ready_callback if asked to execute a timer; reduce usage of void pointers * have the executor notify waitable fiddle with guard condition callbacks only if necessary Signed-off-by: Alberto Soragna <[email protected]>
This PR introduces the events-executor based on the design here ros2/design#305 and the already-existing open-source implementation in https://github.com/irobot-ros/events-executor.
FYI @clalancette @wjwwood @mjcarroll @mauropasse @bpwilcox
This PR currently targets Michael's branch as it depends on it.
Will target the main branch after this PR is merged.
#2143