-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): make linker aspect run in constant time per target
Previously, for every transitive dependency of a node binary target, the module_mappings_aspect had a runtime quadratic in the number of mappings: It traverses the mappings of all direct dependencies in a loop and called _link_mapping in its body, which again traverses the mappings. With this commit, the LinkerPackageMappingInfo provider is restructured to hold depsets of mapping entries and node_modules root paths. In this way the aspect invocations for the individual targets never traverse the (partially constructed) mappings. Instead, write_node_modules_manifest flattens the depset only after the aspect has run. If this should ever become a performance bottleneck again, the flattening could be moved into the execution phase by letting a dedicated binary consume the depset wrappen in an Args object. In an experiment with a single medium-sized package.json and a Node binary depending on all targets in the corresponding npm repository, this commit reduces the analysis wall time spent in the aspect implementation from ~30s to ~70ms.
- Loading branch information
1 parent
6d712cd
commit 522fd7c
Showing
4 changed files
with
134 additions
and
114 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
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
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
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