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

pyflyte run & register asynchronously #2276

Merged
merged 8 commits into from
Apr 12, 2024

Conversation

austin362667
Copy link
Collaborator

@austin362667 austin362667 commented Mar 18, 2024

Tracking issue

NA

Why are the changes needed?

To make register task, workflow, and launchplan x2.5 ~ x4 faster in pyflyte run and pyflyte register by leveraging asyncio.

What changes were proposed in this pull request?

  • Make pyflyte run 4x faster #2267: A neat workaround by @pingsutw for sync grpc clients.
  • Entities serialization is not enough in async approach.
    • It's necessary to separate registered entities into "task" and "non-task" categories in orders. This is because we can ensure flyteadmin returns a task registration response before registering workflows that depend on it.

How was this patch tested?

Setup process

After introducing localhost network latency to 1000ms per request, we can simulate network IO-intensive operations to cloud services (e.g., object storage, Kubernetes cluster, FlyteAdmin) on your own desktop. This way, we can finally evaluate performance improvements through asyncio without setup a real cluster outside. Otherwise, the Flyte sandbox cluster residing in macOS is just too fast to measure.

Steps to reproduce network condition:

  1. sudo pfctl -E: Enabling the latency setup in packfilter.
  2. sudo dnctl pipe 1 config delay 1000ms && echo "dummynet in from any to any pipe 1" | sudo pfctl -f -: Adding 1000ms latency to every dummynet requests.
  3. sudo pfctl -F all -f /etc/pf.conf: To reset and remove the delay.

Don't forget set latency back to 0 to get your original network speed.

Screenshot 2024-03-18 at 3 15 17 PM

Screenshots

  • The registration elapsed time reduced from 34.1s to 16.1s after introducing asynchronous registration.
  • Register, 9 task, 1 wf, 1 lp.

1. Register in the sync manner: 21.1s

  1. python3 -m cProfile -o sync_requests_500ms.prof ./flytekit/clis/sdk_in_container/pyflyte.py register ./workflow.py
  2. snakeviz ./sync_requests_500ms.prof
  • Screenshot 2024-03-23 at 7 43 15 AM

2. Register in the async manner: 6.05s

  1. python3 -m cProfile -o async_requests_500ms.prof ./flytekit/clis/sdk_in_container/pyflyte.py register ./workflow.py
  2. snakeviz ./async_requests_500ms.prof
  • Screenshot 2024-03-23 at 7 44 57 AM

3. Run in the async manner: 5.95s

  1. python3 -m cProfile -o async_requests_500ms_run.prof ./flytekit/clis/sdk_in_container/pyflyte.py run --remote ./workflow.py wf
  2. snakeviz ./async_requests_500ms_run.prof
  • Screenshot 2024-03-26 at 2 19 59 PM

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 18, 2024
@austin362667 austin362667 changed the title [WIP] pyflyte remote run: asynchronous registration [WIP] pyflyte run --remote: asynchronous registration Mar 18, 2024
Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 96.96970% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 83.57%. Comparing base (bf38b8e) to head (47185ee).
Report is 5 commits behind head on master.

❗ Current head 47185ee differs from pull request most recent head f0eab0a. Consider uploading reports for the commit f0eab0a to get more accurate results

Files Patch % Lines
flytekit/remote/remote.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2276      +/-   ##
==========================================
+ Coverage   83.04%   83.57%   +0.52%     
==========================================
  Files         324      324              
  Lines       24861    24658     -203     
  Branches     3547     3510      -37     
==========================================
- Hits        20645    20607      -38     
+ Misses       3591     3421     -170     
- Partials      625      630       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@austin362667 austin362667 force-pushed the austin362667/asyncio_register branch from acd159d to 3bbb889 Compare March 19, 2024 19:44
@austin362667 austin362667 changed the title [WIP] pyflyte run --remote: asynchronous registration pyflyte run& register asynchronously Mar 19, 2024
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 20, 2024
@austin362667 austin362667 force-pushed the austin362667/asyncio_register branch from fcf4332 to 110375c Compare March 20, 2024 13:37
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 20, 2024
@austin362667 austin362667 force-pushed the austin362667/asyncio_register branch 4 times, most recently from c30c359 to 1d1f7d4 Compare March 22, 2024 23:54
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 26, 2024
flytekit/remote/remote.py Outdated Show resolved Hide resolved
flytekit/remote/remote.py Outdated Show resolved Hide resolved
Signed-off-by: Austin Liu <[email protected]>

fix

Signed-off-by: Austin Liu <[email protected]>
Signed-off-by: Austin Liu <[email protected]>

lint

Signed-off-by: Austin Liu <[email protected]>

fix dependency

Signed-off-by: Austin Liu <[email protected]>

fix dependency

Signed-off-by: Austin Liu <[email protected]>

fix dependency

Signed-off-by: Austin Liu <[email protected]>

fix dependency

Signed-off-by: Austin Liu <[email protected]>

fix

Signed-off-by: Austin Liu <[email protected]>

lint

Signed-off-by: Austin Liu <[email protected]>
@austin362667 austin362667 force-pushed the austin362667/asyncio_register branch 2 times, most recently from 4859018 to e3b167a Compare April 10, 2024 08:07
Signed-off-by: Austin Liu <[email protected]>

clean up

Signed-off-by: Austin Liu <[email protected]>

clean up

Signed-off-by: Austin Liu <[email protected]>

clean up

Signed-off-by: Austin Liu <[email protected]>

clean up

Signed-off-by: Austin Liu <[email protected]>
@austin362667 austin362667 force-pushed the austin362667/asyncio_register branch from e3b167a to da60031 Compare April 10, 2024 08:08
tests/flytekit/integration/remote/test_remote.py Outdated Show resolved Hide resolved
flytekit/tools/repo.py Outdated Show resolved Hide resolved
Signed-off-by: Austin Liu <[email protected]>
@dosubot dosubot bot added the lgtm This PR has been approved by maintainer label Apr 12, 2024
@pingsutw pingsutw mentioned this pull request Apr 12, 2024
3 tasks
@pingsutw pingsutw merged commit 886330f into flyteorg:master Apr 12, 2024
47 checks passed
fiedlerNr9 pushed a commit that referenced this pull request Jul 25, 2024
Signed-off-by: Austin Liu <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
@austin362667 austin362667 changed the title pyflyte run& register asynchronously pyflyte run & register asynchronously Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants