Skip to content

Use spin() in component_manager_isolated.hpp - #1881

Merged
ivanpauno merged 2 commits into
masterfrom
asoragna/spin-component-isolated
Feb 9, 2022
Merged

ivanpauno merged 2 commits into
masterfrom
asoragna/spin-component-isolated

Conversation

@alsora

@alsora alsora commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator

Replace spin_until_future_complete with spin in component_manager_isolated.hpp.

spin_until_future_complete() is more inefficient as it needs to check the state of the future and the timeout after every work iteration.

This PR addresses the race-condition issues mentioned in #1781 by using the recently added is_spinning() API

Tests on the navigation stack show 10% less CPU usage when using spin() rather than spin_until_future_complete()

FYI @SteveMacenski @gezp @ivanpauno

…lated.hpp

spin_until_future_complete() is more inefficient as it needs to check the state of the future and the timeout after every work iteration

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@fujitatomoya

Copy link
Copy Markdown
Collaborator

@alsora

Tests on the navigation stack show 10% less CPU usage when using spin() rather than spin_until_future_complete()

sounds great, would you mind sharing the platform you benchmarked this?

@alsora

alsora commented Feb 1, 2022

Copy link
Copy Markdown
Collaborator Author

@fujitatomoya the tests have been carried out by @gezp, he can definitely provide you more details but I think the 10% less cpu was on a raspberry pi 4, while on x86 the improvement was ~5%

@fujitatomoya

Copy link
Copy Markdown
Collaborator

Rasp4 is one of the common benchmark platform we have too, this is good information. thanks!

@ivanpauno

Copy link
Copy Markdown
Member

LGTM with green CI

@alsora

alsora commented Feb 4, 2022

Copy link
Copy Markdown
Collaborator Author

CI

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@alsora

alsora commented Feb 5, 2022 •

Copy link
Copy Markdown
Collaborator Author

Hi, can someone give a look at the windows CI above? It says that there are more than 70 test failures.

They all seem unrelated tests to what I'm doing here, but they are really too many to ignore.

Looking at the logs it may also seem an infrastructure issue, with some tests unable to start.
Do you have any insight?

@ivanpauno

Copy link
Copy Markdown
Member

@ivanpauno

Copy link
Copy Markdown
Member

Ignoring the windows pytest issues that also happen on nightlies, going in!

@ivanpauno
ivanpauno merged commit 43db06d into master Feb 9, 2022
@delete-merged-branch
delete-merged-branch Bot deleted the asoragna/spin-component-isolated branch February 9, 2022 14:45
bartalor pushed a commit to bartalor/rclcpp that referenced this pull request Jul 15, 2026
* replace spin_until_future_complete with spin in component_manager_isolated.hpp

spin_until_future_complete() is more inefficient as it needs to check the state of the future and the timeout after every work iteration

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>

* fix uncrustify error

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
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.

4 participants