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

[Serve] Use Async Handle for DAG Execution #27411

Merged
merged 22 commits into from Aug 7, 2022

Conversation

simon-mo
Copy link
Contributor

@simon-mo simon-mo commented Aug 3, 2022

Signed-off-by: simon-mo simon.mo@hey.com

Why are these changes needed?

This PR replaces the sync handle usage in deployment graph with async handle. It uses the following method

  • Change async handle's .remote return value as a asyncio.Task instead of a coroutine. This doesn't change the UX ref = await handle.remote() but it allows the result to be awaited twice by DAG code.
  • DAG still synchronously call .execute and get the asyncio.Task back.
  • The tasks are propagated directly to downstream's .remote call.
  • In the router's execution path, we use PyObjScanner to find all occurrence of asyncio.Task and resolve them in batch.
  • Generalized PyObjScanner to handle arbitrary source type for replacement.
  • Improved performance of PyObjScanner so it will not serialize input objects.

This PR is code complete and ready for review. Before merge, I'll update the documentation and example code. Add more tests.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
@simon-mo simon-mo changed the title wip async handle for dag execution [Serve] Use Async Handle for DAG Execution Aug 4, 2022
@simon-mo simon-mo marked this pull request as ready for review August 4, 2022 03:22
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
to internal data structures, preventing actually writing them to
the buffer.
"""
if obj is _get_object or obj is _get_object:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate

Signed-off-by: simon-mo <simon.mo@hey.com>
@simon-mo
Copy link
Contributor Author

simon-mo commented Aug 4, 2022

cc @iycheng @jiaodong @suquark for PyObjScanner changes.

index = len(self._found)
self._found.append(obj)
return _get_node, (id(self), index)
else:
index = len(self._objects)
self._objects.append(obj)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we do the dict object to do append?

Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for adding unit tests to the PyObjScanner, that class makes me a bit nervous in general.

Only concern is exposing this RayServeLazyAsyncHandle as a user-facing class... if we can fix that for the release, great, but not a complete dealbreaker.

self._found = None
# List of other objects found during the serializatoin pass.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# List of other objects found during the serializatoin pass.
# List of other objects found during the serialization pass.

@simon-mo
Copy link
Contributor Author

simon-mo commented Aug 4, 2022

microbenchmark seems to be normal range.
before
after
percent change:

0.13
-2.24
-1.68
0.52
2.43
1.61
1.24
0.36
2.51
-4.45
-4.46
-0.00
3.67
0.93
3.99
-3.16
1.95
-4.82
-0.45
-1.26
2.91
-1.53
0.60
-4.42

Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
@fishbone fishbone self-assigned this Aug 5, 2022
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
Signed-off-by: simon-mo <simon.mo@hey.com>
@simon-mo simon-mo requested a review from jiaodong as a code owner August 6, 2022 20:44
@simon-mo simon-mo requested review from shrekris-anyscale and a team as code owners August 6, 2022 20:44
Signed-off-by: simon-mo <simon.mo@hey.com>
@simon-mo simon-mo removed the request for review from a team August 6, 2022 20:47
Signed-off-by: simon-mo <simon.mo@hey.com>
@simon-mo simon-mo added the tests-ok The tagger certifies test failures are unrelated and assumes personal liability. label Aug 7, 2022
@simon-mo simon-mo merged commit efee158 into ray-project:master Aug 7, 2022
simon-mo added a commit to simon-mo/ray that referenced this pull request Aug 7, 2022
Signed-off-by: simon-mo <simon.mo@hey.com>
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
Signed-off-by: Stefan van der Kleij <s.vanderkleij@viroteq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests-ok The tagger certifies test failures are unrelated and assumes personal liability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants