Comments (7)
I think the use case for the multi-threaded executor is to take advantage of multiple core systems to execute as many jobs in parallel as possible. Though I also don't recall seeing it mentioned in the design documents. If you take a look at multi_threaded_executor.hpp
, it uses std::thread::hardware_concurrency
to determine the number of threads to spawn:
http://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency
This call is supposed to return the number of cores of the CPU executing the code, though it might not be implemented on all platforms/architectures.
It's up to the user to avoid data races in the MultiThreadedExecutor. It provides a mutex to ensure that only one thread accesses the get_next_executable
function, but there isn't more synchronization than that.
from rclcpp.
Yes, the multi-threaded executor that is currently implemented will not tie work coming from a particular node to a particular thread.
from rclcpp.
The executor could be more sophisticated and have some notion of affinity. We don't currently have this, but it would be interesting to try it out to see if our abstractions provide enough information to achieve it.
from rclcpp.
Agreed. I'm not sure what @BobDean had in mind when he opened this question, but one use case I see for thread affinity is prioritizing work from a certain node by scheduling it in a high-priority/realtime thread.
It should be fairly easy to implement a "ThreadAffinityExecutor" (or whatever we want to call it), since the AnyExecutable
struct has a shared pointer to the parent node of the executable.
from rclcpp.
I am wondering about its applicability to tightly timed nodes, and the ability to debug multi-threaded behavior when the worker is moving between threads between executions. what is the use case for the multithreaded executor? did i miss it on the design docs?
from rclcpp.
but there isn't more synchronization than that.
Well, there is also the callback groups, which can prevent certain user provided code from being run in parallel or in a reentrant fashion. This might let the user avoid having their own synchronization patterns and can allow the system to avoid things like locking the worker threads. See my roscon talk:
http://roscon.ros.org/2014/wp-content/uploads/2014/07/ROSCON-2014-Why-you-want-to-use-ROS-2.pdf (see page 17)
from rclcpp.
@BobDean I'm going to close this issue too. I think my most recent comment addresses some of the "why multithreaded executor?". Another thing I'll add is that the multi-threaded executor allows you to utilize as much of the system as possible when your CPU bound (basically a thread-pool as you said). The difference is that allows uncoordinated and uncoupled pieces of code (separate nodes, a.k.a. nodelets) to shared the thread pool, which is a bit above and beyond what a normal thread-pool does for you.
Feel free to continue the discussion or move it to the mailing list.
from rclcpp.
Related Issues (20)
- Shutdown transition on base lifecycle node dtor may lead to segaults on subclass-registered shutdown callback HOT 6
- `on_shutdown` callback not called when `shutdown` transition is triggered on dtor HOT 2
- ABI/API Compliance Checker in github workflow HOT 2
- [rclcpp] C++ lib leaking `rclcpp::Node()` can cause segfaults at `dlclose()` HOT 3
- Feature Request: Dynamic Type Handling for Generic Subscriptions HOT 15
- Action: rclcpp_action::Client goal response and feedback order not in send order HOT 5
- EventsExecutor doesn't support rcl guard conditions HOT 3
- Retrieving(get_parameter()) value of parameter of type std::vector<int> won't build HOT 3
- :farmer: `test_client_common` and `test_service` failing in Rolling and Jazzy connext nightlies HOT 2
- Issue with RCLCPP THROTTLE logging in the plugin based approach HOT 4
- :farmer: connext test regressions in `test_subscription_topic_statistics` HOT 8
- Double spin required since 28.2.0 HOT 20
- backport request : issue 2492 to humble HOT 1
- ROS2 node having long name throws confusing error HOT 2
- Broken API document formatting for Publisher and ParameterEventHandler HOT 2
- A way to get the parsed global arguments from within the Node or NodeOptions HOT 2
- :farmer: TestClient.client_qos failing in Iron Connext
- :farmer: TestServiceIntrospection.service_introspection_enable_disable_events failing in Rolling, Jazzy and Iron Connext HOT 1
- rclcpp_action::ClientBase::SharedPtr is aliased to rclcpp::Waitable HOT 1
- Possible bug: executor_entities_collection.hpp::update_entities HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rclcpp.