Skip to content
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

Fix "roscpp multithreaded spinners eat up CPU when callbacks take too long" #2377

Open
wants to merge 2 commits into
base: noetic-devel
Choose a base branch
from

Conversation

meyerj
Copy link
Contributor

@meyerj meyerj commented Oct 7, 2024

Resolves #2341:

Issue #1545 was fixed in ROS melodic, but not noetic.

The fix for the issue took a rather meandering rout to getting in, but PR #1684 and PR #2014 both seem related.

As far as I can tell, the offending functions in noetic are the same as in melodic pre fix, so this might be as easy as cherry picking those changes over.

These two commits were cherry-picked from branch melodic-devel, with some merge conflict resolutions in test/test_roscpp/test/test_callback_queue.cpp due to updates in #2121.

Not sure whether #2121 resolving #1980 is related and would not even have been necessary with these two commits from melodic-devel? I have not checked those two in detail yet.

cwecht and others added 2 commits October 7, 2024 18:14
* Better fix for slow callbacks CPU throttling.

* More versatile callback queue test.

* Finished cherry-pick merge to melodic-devel.

* libros: moved define

* roscpp: implementet ros#1608 without ABI/API breaks

* /test_roscpp: fake_message is in a header now...

* test_roscpp: fixed sign-compare warning

* stabilized test

* CallbackQueue: use SteadyTime instead of WallTime to get independent of system-time changes

* style only

* Update clients/roscpp/include/ros/callback_queue.h

Co-authored-by: Johannes Meyer <[email protected]>

Co-authored-by: Martin Pecka <[email protected]>
Co-authored-by: CTU base <robot@ctu-base>
Co-authored-by: Martin Pecka <[email protected]>
Co-authored-by: Christopher Wecht <christopher.wechtstudent.kit.edu>
Co-authored-by: Dirk Thomas <[email protected]>
Co-authored-by: Johannes Meyer <[email protected]>
* roscpp: simplify implementation of CallbackQueue::callOne()

Replace duplicate wait_for() call in CallbackQueue::callOne() with a loop and a call to wait_until().

* roscpp: return TryAgain from CallbackQueue::callOne(timeout) immediately if timeout.isZero()

... and if none of the other result conditions holds (i.e. the queue is Empty or Disabled).

Co-authored-by: Johannes Meyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

roscpp multithreaded spinners eat up CPU when callbacks take too long
3 participants