8000 Adding custom thread names to component_container_isolated · Issue #2818 · ros2/rclcpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding custom thread names to component_container_isolated #2818

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

Open
Aposhian opened this issue Apr 16, 2025 · 7 comments
Open

Adding custom thread names to component_container_isolated #2818

Aposhian opened this issue Apr 16, 2025 · 7 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

< 8000 a class="d-inline-block" data-hovercard-type="user" data-hovercard-url="/users/Aposhian/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/Aposhian">@Aposhian
Copy link
Contributor

Description

Since component_container_isolated spins up a thread for each node, it would be nice to name those threads in a way that operating system tools can identify them easily. This would involve writing code that uses the platform-specific API's with conditional compilation that sets the thread name at the beginning.

Motivation

Identify resource usage quickly by node using tools like htop, system monitor, task manager, etc.

Design / Implementation Considerations

I think it would be best to use the fully qualified node name, but with namespaces, this could quickly get longer than the character limit for thread names, and would require truncation. So it might be better to do just the node name itself, or maybe some kind of identifier, maybe just an index, that could be logged with debug logs?

Additional Information

No response

@Aposhian Aposhian added the enhancement New feature or request label Apr 16, 2025
@roncapat
Copy link
Contributor

I second this. With Linux 'pthread' the character limit is 16, I believe also the null terminating character is included in this count. I personally truncate the node name (no namespaces) to length 15. This could create ambiguities if multiple nodes share the same 15-char name prefix...

I would suggest to print in debug logs the full mapping between node (namespace+name) and assigned thread name. Maybe "wasting" the initial 2-3 chars to prepend a sequential number would be a trade-off to consider IMHO.

@fujitatomoya
Copy link
Collaborator

it could be useful for frontend monitoring tool, but what if ComponentManagerIsolated is templated with rclcpp::executors::MultiThreadedExecutor? any thoughts?

@Aposhian
Copy link
Contributor Author

it could be useful for frontend monitoring tool, but what if ComponentManagerIsolated is templated with rclcpp::executors::MultiThreadedExecutor? any thoughts?

I suppose even if you are using multi threaded executor, each component will have an isolated thread pool, correct? So it could still be helpful to just have all of the threads in a components pool be named after the node.

@fujitatomoya
Copy link
Collaborator

each component will have an isolated thread pool, correct?

yes, but we need to update the MultiThreadedExecutor class to allow the application to change the names of all threads of it. we can control the main thread, but not all child threads created by MultiThreadedExecutor class.

So it could still be helpful to just have all of the threads in a components pool be named after the node.

are you suggesting that all the child thread in the MultiThreadedExecutor should inherit the same name from main thread of that?

@Aposhian
Copy link
Contributor Author

are you suggesting that all the child thread in the MultiThreadedExecutor should inherit the same name from main thread of that?

I think so, because then at least different components with their own executors would have differently named threads from each other.

@MichaelOrlov MichaelOrlov added the help wanted Extra attention is needed label May 1, 2025
@MichaelOrlov
Copy link
Contributor

At a weekly ROS 2 issues triage meeting, we agreed that yes, it makes sense to add it. However, help wanted here with implementation.

@Aposhian
Copy link
Contributor Author
Aposhian commented May 1, 2025

I can take a try at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants
0