-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii): slow with deep dependency tree (#3294)
The `_loadDependencies` calls in jsii were taking a very long time with a deep dependency tree (like in `cdk-watchful`). The reason for this is another accidentally quadratic algorithm: every dependency would be processed for every time it transitively occurred in any of the dependency graph's dependencies. For a reason I don't completely understand yet, the timings got a whole lot worse recently in 1.49.0. Refactor to add some short-circuiting: if a directory has already been processed, no need to recurse into it yet again (the first recursion pass on that tree will have gathered all the information that is necessary already). I stared long and hard at the `semver-intersect` call... but as far as I could tell we would never be in a situation where `packageVersions` would/could already contain a previous version, and the intersection would actually do anything. I validated with a print statement. As far as I can tell this was dead code and I removed it. Timings on the `cdk-watchful` project for reference: ``` $ time npx tsc 5.88 real 9.62 user 0.38 sys $ time npx jsii@1.47.0 35.64 real 39.38 user 0.81 sys $ time npx jsii@1.49.0 334.26 real 239.60 user 141.71 sys $ time /path/to/my/jsii 6.11 real 9.82 user 0.42 sys ``` Diff a `diff` between a jsii assembly produced with the old and the new version. No change.
- Loading branch information
Showing
1 changed file
with
123 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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