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

fix(builtin): make linker aspect run in constant time per target #3301

Commits on Jan 31, 2022

  1. 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.
    fmeum committed Jan 31, 2022
    Configuration menu
    Copy the full SHA
    312dca0 View commit details
    Browse the repository at this point in the history