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

Ngtsc much speed such fast #34332

Closed
wants to merge 7 commits into from

Commits on Dec 12, 2019

  1. perf(ivy): share instances of DomElementSchemaRegistry

    To create a binding parser, an instance of `ElementSchemaRegistry` is
    required. Prior to this change, each time a new binding parser was
    created a new instance of `DomElementSchemaRegistry` would be
    instantiated. This is an expensive operation that takes roughly 1ms per
    instantiation, so it is key that multiple allocations are avoided.
    
    By sharing a single `DomElementSchemaRegistry`, we avoid two such
    allocations, i.e. save ~2ms, per component template.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    2ba13a8 View commit details
    Browse the repository at this point in the history
  2. perf(ivy): cache export scopes extracted from declaration files

    The export scope of NgModules from external compilations units, as
    present in .d.ts declarations, does not change during a compilation so
    can be easily shared. There was already a cache but the computed export
    scope was not actually stored there. This commit fixes that.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    a0c215c View commit details
    Browse the repository at this point in the history
  3. perf(ivy): use module resolution cache

    During TypeScript module resolution, a lot of filesystem requests are
    done. This is quite an expensive operation, so a module resolution cache
    can be used to speed up the process significantly.
    
    This commit lets the Ivy compiler perform all module resolution with a
    module resolution cache. Note that the module resolution behavior can be
    changed with a custom compiler host, in which case that custom host
    implementation is responsible for caching. In the case of the Angular
    CLI a custom compiler host with proper module resolution caching is
    already in place, so the CLI already has this optimization.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    3d45bb7 View commit details
    Browse the repository at this point in the history
  4. perf(compiler): optimize cloning cursors state

    On a large compilation unit with big templates, the total time spent in
    the `PlainCharacterCursor` constructor was 470ms. This commit applies
    two optimizations to reduce this time:
    
    1. Avoid the object spread operator within the constructor, as the
    generated `__assign` helper in the emitted UMD bundle (ES5) does not
    optimize well compared to a hardcoded object literal. This results in a
    significant performance improvement. Because of the straight-forward
    object literal, the VM is now much better able to optimize the memory
    allocations which makes a significant difference as the
    `PlainCharacterCursor` constructor is called in tight loops.
    
    2. Reduce the number of `CharacterCursor` clones. Although cloning
    itself is now much faster because of the optimization above, several
    clone operations were not necessary.
    
    Combined, these changes reduce the total time spent in the
    `PlainCharacterCursor` constructor to just 10ms.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    114a2b4 View commit details
    Browse the repository at this point in the history
  5. perf(compiler): use a shared interpolation regex

    The template parser has a certain interpolation config associated with
    it and builds a regular expression each time it needs to extract the
    interpolations from an input string. Since the interpolation config is
    typically the default of `{{` and `}}`, the regular expression doesn't
    have to be recreated each time. Therefore, this commit creates only a
    single regular expression instance that is used for the default
    configuration.
    
    In a large compilation unit with big templates, computing the regular
    expression took circa 275ms. This change reduces this to effectively
    zero.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    18e45c7 View commit details
    Browse the repository at this point in the history
  6. perf(compiler): speed up i18n digest computations

    Avoids the usage of array destructuring, as it introduces calls to
    a `__values` helper function in ES5 that has a relatively high
    performance impact. This shaves off roughly 130ms of CPU time for a
    large compilation with big templates that uses i18n.
    JoostK committed Dec 12, 2019
    Configuration menu
    Copy the full SHA
    dfe55ca View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    da6046b View commit details
    Browse the repository at this point in the history