Improve performance of package ordering/tagging after version solving#2906
Merged
Conversation
… has been completed
Member
|
@sdispater this might need your review. |
|
Can I do anything to help this patch reach production asap? It's among the top fixes on my "urgently needed" list. |
31ea9e8 to
2605598
Compare
|
This works like a charm. Dependencies that took 40 minutes in total (20 resolving + 20 locking) are now resolved in 18 seconds. Thank you @zweger ! |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR greatly improves the performance of package ordering/tagging which occurs during package solving, after the version solving itself has been completed. In certain cases, the current algorithm has exponential time complexity and starts to really break down when the package dependency graph is dense. I've added a test case for one such scenario, where the dependencies form a transitive tournament. On
masterthis test takes several minutes to run with my hardware, but only takes around 100ms with this patch.I've noticed on personal projects that it's very easy to run into this issue when using
aws_cdk.At the core of the new algorithm is a depth-first search which is used to compute a topological sort of the packages. Using the topological ordering, the longest path / depth of each package can be computed.
Along the way I noticed that the current algorithm does not correctly check for dependency cycles and in certain cases will trigger a
RecursionError. I've added a test case for this scenario as well.Pull Request Check List
This may be related to #2642 and #2149, which both mention using
aws_cdk.