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

Use a single executor instance for spinning in client_async_callback. (backport #382) #385

Open
wants to merge 1 commit into
base: jazzy
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented May 16, 2024

In the current code, it calls rclpy.spin_once(), which instantiates a new executor, adds the node to it, executors one work item, then removes the node and destroys the executor.

Besides being inefficient, the problem with that sequence is that adding a node to the executor actually ends up being an "event", and so the work item that gets returned can be just the work of adding the node, over and over again. For reasons I admit I don't fully understand, this only happens with rmw_cyclonedds_cpp, not with rmw_fastrtps_cpp.

Regardless, the much more performant thing to do is to create an executor at the beginning of the example and to just spin on that. This eliminates adding it to the node constantly, and makes this work with all RMWs.


This is an automatic backport of pull request #382 done by Mergify.

…#382)

In the current code, it calls rclpy.spin_once(), which
instantiates a new executor, adds the node to it, executors
one work item, then removes the node and destroys the executor.

Besides being inefficient, the problem with that sequence
is that adding a node to the executor actually ends up
being an "event", and so the work item that gets returned
can be just the work of adding the node, over and over again.
For reasons I admit I don't fully understand, this only happens
with rmw_cyclonedds_cpp, not with rmw_fastrtps_cpp.

Regardless, the much more performant thing to do is to create
an executor at the beginning of the example and to just spin
on that.  This eliminates adding it to the node constantly,
and makes this work with all RMWs.

Signed-off-by: Chris Lalancette <[email protected]>
(cherry picked from commit 7e47aee)

# Conflicts:
#	rclpy/services/minimal_client/examples_rclpy_minimal_client/client_async_callback.py
Copy link
Contributor Author

mergify bot commented May 16, 2024

Cherry-pick of 7e47aee has failed:

On branch mergify/bp/jazzy/pr-382
Your branch is up to date with 'origin/jazzy'.

You are currently cherry-picking commit 7e47aee.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   rclpy/services/minimal_client/examples_rclpy_minimal_client/client_async_callback.py

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@ahcorde
Copy link
Contributor

ahcorde commented May 24, 2024

@clalancette probably we should backport this other one too https://github.com/ros2/examples/pull/379/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

2 participants