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

More optimized lazy-loading of provider information #17304

Merged
merged 1 commit into from
Jul 29, 2021

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Jul 29, 2021

With this change we truly lazy-load hooks and external_links only
when we need them. Previously they were loaded when any of the
properties of ProvidersManager was used, but with this change
in some scenarios where only extra links are used or when we
only need list of providers, but we do not need details on
which custom hooks are needed, there will be much
faster initialization. This is mainly for some CLI commands
(for example airlfow providers list is much faster now), but
also in some scenarios where for example .get_conn() is never
used in Tasks, tasks might also never need to import/load the hooks
and they might perform faster, with smaller memory footprint.

@potiuk potiuk requested a review from ashb as a code owner July 29, 2021 07:50
@potiuk potiuk force-pushed the optimize-providers-manager-lazy-loading branch 5 times, most recently from 636dc8a to 6daa185 Compare July 29, 2021 08:01
@potiuk potiuk changed the title Optimize providers manager lazy loading More optimized lazy-loading of provider information Jul 29, 2021
@potiuk potiuk requested a review from uranusjr July 29, 2021 08:10
@potiuk potiuk force-pushed the optimize-providers-manager-lazy-loading branch from 6daa185 to d2aa352 Compare July 29, 2021 08:16
@potiuk potiuk force-pushed the optimize-providers-manager-lazy-loading branch 2 times, most recently from 6b95b4b to 5bce2c6 Compare July 29, 2021 09:30
With this change we truly lazy-load hooks and external_links only
when we need them. Previously they were loaded when any of the
properties of ProvidersManager was used, but with this change
in some scenarios where only extra links are used or when we
only need list of providers, but we do not need details on
which custom hooks are needed, there will be much
faster initialization. This is mainly for some CLI commands
(for example `airlfow providers list` is much faster now), but
also in some scenarios where for example .get_conn() is never
used in Tasks, tasks might also never need to import/load the hooks
and they might perform faster, with smaller memory footprint.
@potiuk potiuk force-pushed the optimize-providers-manager-lazy-loading branch from 5bce2c6 to 2cdd7e2 Compare July 29, 2021 09:43
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jul 29, 2021
@potiuk
Copy link
Member Author

potiuk commented Jul 29, 2021

Tansient errors only - seems so local_task_job became flaky after recent "QUEUED" state intro - might be worth looking at @ephraimbuddy - I will make issues for those quickly (and qurarantine them)

@potiuk potiuk merged commit 2dc7aa8 into apache:main Jul 29, 2021
@potiuk potiuk deleted the optimize-providers-manager-lazy-loading branch July 29, 2021 10:15
@kaxil
Copy link
Member

kaxil commented Jul 29, 2021

Should this be in 2.1.3 vs 2.2?

@potiuk potiuk added this to the Airflow 2.1.3 milestone Jul 29, 2021
@potiuk
Copy link
Member Author

potiuk commented Jul 29, 2021

Easy cherry-pick and it is rather save. I added it to 2.1.3

potiuk added a commit to potiuk/airflow that referenced this pull request Aug 2, 2021
With this change we truly lazy-load hooks and external_links only
when we need them. Previously they were loaded when any of the
properties of ProvidersManager was used, but with this change
in some scenarios where only extra links are used or when we
only need list of providers, but we do not need details on
which custom hooks are needed, there will be much
faster initialization. This is mainly for some CLI commands
(for example `airlfow providers list` is much faster now), but
also in some scenarios where for example .get_conn() is never
used in Tasks, tasks might also never need to import/load the hooks
and they might perform faster, with smaller memory footprint.

(cherry picked from commit 2dc7aa8)
kaxil pushed a commit that referenced this pull request Aug 17, 2021
With this change we truly lazy-load hooks and external_links only
when we need them. Previously they were loaded when any of the
properties of ProvidersManager was used, but with this change
in some scenarios where only extra links are used or when we
only need list of providers, but we do not need details on
which custom hooks are needed, there will be much
faster initialization. This is mainly for some CLI commands
(for example `airlfow providers list` is much faster now), but
also in some scenarios where for example .get_conn() is never
used in Tasks, tasks might also never need to import/load the hooks
and they might perform faster, with smaller memory footprint.

(cherry picked from commit 2dc7aa8)
jhtimmins pushed a commit that referenced this pull request Aug 17, 2021
With this change we truly lazy-load hooks and external_links only
when we need them. Previously they were loaded when any of the
properties of ProvidersManager was used, but with this change
in some scenarios where only extra links are used or when we
only need list of providers, but we do not need details on
which custom hooks are needed, there will be much
faster initialization. This is mainly for some CLI commands
(for example `airlfow providers list` is much faster now), but
also in some scenarios where for example .get_conn() is never
used in Tasks, tasks might also never need to import/load the hooks
and they might perform faster, with smaller memory footprint.

(cherry picked from commit 2dc7aa8)
Comment on lines 83 to 84
# This is never executed, but tricks static analyzers (PyDev, PyCharm,)
# into knowing the types of these symbols, and what
# they contain.
Copy link
Contributor

@edwardwang888 edwardwang888 Aug 28, 2021

Choose a reason for hiding this comment

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

@potiuk Was this line meant to be removed? (Sorry if I don't fully understand this PR, the comment just reads a bit funny.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Not at all - you can add PR to bring it back :).

Copy link
Contributor

Choose a reason for hiding this comment

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

@potiuk Thanks! I opened #17884 to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Merged! Quickest contribution EVER!

Copy link
Contributor

@edwardwang888 edwardwang888 Aug 28, 2021

Choose a reason for hiding this comment

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

Thanks! I did not expect my first contribution to be this quick 🙂

edwardwang888 added a commit to edwardwang888/airflow that referenced this pull request Aug 28, 2021
Fixes comment deleted in apache#17304
potiuk pushed a commit that referenced this pull request Aug 28, 2021
Fixes comment deleted in #17304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI area:dev-tools area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants