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

v1.8 Backport of #35157 #35162

Merged
merged 2 commits into from
May 15, 2024
Merged

v1.8 Backport of #35157 #35162

merged 2 commits into from
May 15, 2024

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented May 15, 2024

manual backport of #35157


The use of depends_on in modules can cause large numbers of nodes to become connected to all of the same dependencies. When using Ancestors to walk the graph and find all of these dependencies, there can be a lot of redundant ancestors shared between each of the original nodes, causing an exponential increase in processing time and memory use.

Instead of traversing the graph from each dependency individually, which can frequently end up duplicating results, we can start a walk from all nodes at once, reducing the redundant graph traversals and automatically removing duplicates.

Fixes #35154

A walk can start from multiple roots, so making the Ancestors and
Descendents methods variadic is the easiest way to add access to that
via the API with no changes in existing callers. We can use this from
terraform to avoid repeatedly walking overlapping sets of nodes.
The existing implementation of parentModuleDependsOn would walk each
reference separately, but if there were many dependencies which were all
interconnected, that would end up walking over the same nodes multiple
times, and storing many duplicate results.

Since a graph walk can start at multiple nodes, we use the extended
version of Ancestors to start at all dependencies simultaneously,
reducing the time spend traversing the graph as well as automatically
removing duplicates.
@jbardin jbardin merged commit 41d5430 into v1.8 May 15, 2024
10 checks passed
@jbardin jbardin deleted the backport-35157 branch May 15, 2024 15:39
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant