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

core: use more efficient methods for finding ancestors #35873

Merged
merged 4 commits into from
Oct 18, 2024
Merged

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Oct 17, 2024

Add ancestor equivalents of FirstDescendantsWith and MatchDescendant.

In configurations with long chains of dependencies, we spend a lot of time recording redundant dependency edges, and writing all those dependencies in the state.

Rather than record every possible dependency edge, we can use the new methods above to only record the first managed resource in any lineage, such that the resulting graph is topologically equivalent having removed many transitive edges. For some configurations this can save considerable time and space when handling the state.

While this can remove the bulk of transitive dependencies in a lot of cases, this does not reduce the subgraph of direct dependencies. Take for example a resource X, and a graph with edges X->A X->B A->B. We will still currently record both A and B as dependencies even though the final graph will reduce to just X->A->B. Doing that extra processing is a harder cost-tradeoff to make however, and doesn't seem necessary at this point, whereas this PR is never less efficient than tracking all possible ancestors.

Add ancestor equivalents of FirstDescendantsWith and MatchDescendant
In configurations with long chains of dependencies, we spend a lot of
time recording redundant dependency edges, and writing all those
dependencies in the state.

Rather than record every possible dependency edge, only record the first
managed resource in any lineage, such that the resulting graph is
topologically equivalent having removed many transitive edges. For some
configurations this can save considerable time and space when handling
the state.
Use the more efficient FirstAncestorsWith when connecting dependencies
cause by `depends_on`.
@jbardin jbardin requested a review from a team October 17, 2024 15:11
Copy link
Member

@liamcervante liamcervante left a comment

Choose a reason for hiding this comment

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

Nice!

@jbardin jbardin merged commit 2e4a62d into main Oct 18, 2024
6 checks passed
@jbardin jbardin deleted the jbardin/ancestors branch October 18, 2024 14:09
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants