-
Notifications
You must be signed in to change notification settings - Fork 555
Refactor component containers + Add option for CBG Executor #3134
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
Merged
skyegalaxy
merged 20 commits into
rolling
from
skyegalaxy/component-container-refactor-cbg
Apr 20, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f0fb9c9
Refactor component containers
mini-1235 ff7e25e
Format
mini-1235 7b684e8
add new constructor, node_options_ and thread_num_ to component_manag…
565b9ad
make linter happy
d59094b
replace experimental with EventsCBG
8172c03
add make_executor helper
3f35892
add num_threads as a cli arg
5aea21f
refactor main to use executor helper func. preserve thread_num ros pa…
8b7eadb
update help msg
27e09ca
unused include
2ad9585
update deprecation warning
b125c57
remove --num-threads CLI arg and use the ROS param
2bb8a7f
remove redundant warning
44d8b3f
lint
2ec9c60
update help msg
d80709d
use regular node constructor for single-threaded
829209a
match param name in warning msg
a99095c
lint again
ad73c4f
check for != default instead of < default
f39a5a2
nullify node before reassignment if isolated
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So we have already created a node to read the
thread_numparam. In this case,std::make_sharedwill make another node before moving it intonode. There could be a very small window where two component manager nodes exist here. Can we just defer here somehow?Uh oh!
There was an error while loading. Please reload this page.
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.
Claude originally tried to get around this by creating a
--num-threadscli arg which was shadowed by the ROS param, but I felt like having the two ways of configuring threads leftcomponent_container.cppfeeling cluttered and that it may be another source of confusion. I figured the cost of destroying and rebuilding the node was negligible for the sake of cleaner reading codeThere 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.
@mjcarroll - how about 0bd014e ?
Uh oh!
There was an error while loading. Please reload this page.
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.
Following up on this, I think the creation of a temporary
ComponentManagerto getthread_numcreated a race condition bug.When several isolated containers start concurrently and each has a
LoadComposableNodesrequest waiting on it (the normal launch case), some composables silently never load. It's timing-dependent, so it shows up under real load (on hardware / busy CI) and is easy to miss on a warm single-host machine.My hypothesis on what's happening:
ComponentManager's constructor advertises~/_container/load_nodeunder the container's remapped name. So the load service flaps: advertised (throwaway) → destroyed → re-advertised (real, only served atspin()). ALoadComposableNodesclient that is already waiting can havewait_for_service()catch the throwaway, thencall_async()lands in the teardown gap and the request is dropped — the node never loads.I Claude-coded a fix that doesn't involve creating a new
ComponentManagerand that seems to fix the issue at hand:rolling...botsandus:rclcpp:race-condition-load-composable
I didn't spend more time validating the approach though.
I also made a test in
launch_rosto reproduce the issue:ros2/launch_ros#563
Note that it will only reproduce under heavy CPU load, alternatively, you could use that branch in rclcpp: rolling...botsandus:rclcpp:add-delay-composable
which adds a
sleep, simulating heavy CPU load and making it more likely to occur.@skyegalaxy would you be able to follow up on this?
FYI @doisyg
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.
thanks for reporting this @tonynajjar. I took a look at your branch, and aside from one comment that feels a bit claude-y (about why we're NOT creating two component containers) I think it looks sound. Could you open a pull request to rolling with your branch?
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.
Thanks for the prompt look, will open a PR tomorrow