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

Speed up nested TaskGoups #30284

Merged
merged 2 commits into from
Apr 13, 2023
Merged

Conversation

MarosMK
Copy link
Contributor

@MarosMK MarosMK commented Mar 24, 2023

This PR aims to speed up nested TaskGroups. During the checks in conditions the Task won't have to go into 'depth' to figure out the group_id.
This affects particularly cases where there is deep nesting of TaskGroups.

@boring-cyborg
Copy link

boring-cyborg bot commented Mar 24, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch from 2f5f34b to 17972c7 Compare March 28, 2023 07:27
@uranusjr
Copy link
Member

How much speedup does this produce? The task_group attribute is public and may potentially change and cause breakage too easily. If the main slowdown is from child_id calculation, it may be a better idea to cache at that level instead.

@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch 2 times, most recently from 7d272a3 to 2cdafad Compare March 29, 2023 15:50
@MarosMK
Copy link
Contributor Author

MarosMK commented Mar 29, 2023

@uranusjr
The code changes were updated (no caching of group_id) so hopefully there is now less risk at stake and the speedup is the same as before.
For the time improvement, if we take nested groups of 3 (each task has 3 child tasks) and we go into 'depth' of 6 layers, the dag loading is faster by 7.7s. Or 4 nested groups with 5 layers, it is faster by 3.5s. It depends on how many layers you have and how many task in each layer.
We do use a lot of nested groups so this would be an improvement.

@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch from 2cdafad to 458baf7 Compare March 30, 2023 07:56
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me and should be OK to be merged. One more potential path to optimise things though; feel free to investigate in another PR.

airflow/utils/task_group.py Show resolved Hide resolved
@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch 2 times, most recently from 5d36f35 to 2f6e26b Compare March 31, 2023 08:03
@MarosMK MarosMK requested a review from uranusjr April 3, 2023 08:00
@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch 2 times, most recently from acbf148 to cd613c5 Compare April 3, 2023 08:34
@MarosMK MarosMK force-pushed the feature/speed_up_task_group branch from cd613c5 to ffe1d15 Compare April 3, 2023 09:46
@MarosMK
Copy link
Contributor Author

MarosMK commented Apr 3, 2023

@uranusjr, thanks for approving.

Any expected timeline for merging this and including it in a new release?

@uranusjr
Copy link
Member

You just broke the PR…

@eladkal
Copy link
Contributor

eladkal commented Apr 10, 2023

You just broke the PR…

it's a rebase done from the Ui while github had a bug https://github.com/orgs/community/discussions/51948
They reported that closing and opening the PR will fix the problem.. lets see

@eladkal eladkal closed this Apr 10, 2023
@eladkal eladkal reopened this Apr 10, 2023
@uranusjr uranusjr removed the request for review from ashb April 10, 2023 14:09
@eladkal eladkal added this to the Airflow 2.6.0 milestone Apr 13, 2023
@eladkal eladkal added the type:improvement Changelog: Improvements label Apr 13, 2023
@eladkal eladkal merged commit 2c66b24 into apache:main Apr 13, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 13, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

wookiist pushed a commit to wookiist/airflow that referenced this pull request Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants