-
Notifications
You must be signed in to change notification settings - Fork 418
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
High CPU usage when using MultiThreadedExecutor & TimerCallback #1618
Comments
checked with source build ros2/ros2@0e6cc1c, i cannot reproduce the problem.
root@134f29e8f25f:~/ros2_ws/colcon_ws# ros2 run sample sample
[INFO] [1617930704.586983609] [chatter]: update is called
[INFO] [1617930705.587006977] [chatter]: update is called
[INFO] [1617930706.587756538] [chatter]: update is called
...<snip>
root@134f29e8f25f:~# pgrep -l sample
14461 sample
root@134f29e8f25f:~# pidstat -p 14461 1
Linux 5.4.0-70-generic (134f29e8f25f) 04/09/2021 _x86_64_ (24 CPU)
09:39:00 AM UID PID %usr %system %guest %wait %CPU CPU Command
09:39:01 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:02 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:03 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:04 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:05 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:06 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:07 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:08 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:09 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:10 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
09:39:11 AM 0 14461 0.00 0.00 0.00 0.00 0.00 2 sample
...<snip> |
We had the same issue over at ros2-control: ros-controls/ros2_control#275 Even without any load, the multithreaded executor would exhaust all CPU and could not achieve the desired update rates. |
I think this can be also fixed by #1516, which introduces MutexTwoPriorities to reduce race condition for before MutexTwoPriorities, it is really hard to remove
it is because the same mutex
there is a lot of race condition, and this makes really hard to remove executed btw, i do not think MutexTwoPriorities is perfect solution. in theory i might be missing something, any comments are welcome 😄 |
I'm writing on behalf of @k0suke-murakami. Thank you for your information. We have confirmed that the CPU usage decreased significantly on master. (We were originally testing on foxy) Do you know if this feature is going to be back-ported to foxy? |
good to know 👍 thanks for the confirmation.
as far as i see, it will break the ABI. so i guess it is unlikely to happen...but i think this could change user experience significantly. @ivanpauno @clalancette what do you think about this backport? |
Yes, if it changes ABI, we can't put it into Foxy. However, if someone were to come up with an ABI-compatible version of it, we could consider putting that into Foxy. |
Thanks. We will take a deeper look into #1516 and see if we can do that without breaking the ABI. |
I cannot imagine a ABI compatible fix for this, but if someone can figure out a ABI compatible fix that would be great. The bug is fixed in master though, so I think that we can close this ticket. |
Bug report
Required Info:
Steps to reproduce issue
Clone test package: https://github.com/k0suke-murakami/multi_thread_sample
Build & Run
Expected behavior
Low CPU usage.
When executed with a single-threaded executor, the CPU usage is almost 0%.
Actual behavior
Reaches 40% CPU usage in my environment.
Additional information
The text was updated successfully, but these errors were encountered: