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
perf: AOT compilation optimizations (patch) #38749
Closed
Closed
Conversation
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
For the compilation of a component, the compiler has to prepare some information about the directives and pipes that are used in the template. This information includes an expression for directives/pipes, for usage within the compilation output. For large NgModule compilation scopes this has shown to introduce a performance hotspot, as the generation of expressions is quite expensive. This commit reduces the performance overhead by only generating expressions for the directives/pipes that are actually used within the template, significantly cutting down on the compiler's resolve phase.
When type-checking a component, the declaring NgModule scope is used to create a directive matcher that contains flattened directive metadata, i.e. the metadata of a directive and its base classes. This computation is done for all components, whereas the type-check scope is constant per NgModule. Additionally, the flattening of metadata is constant per directive instance so doesn't necessarily have to be recomputed for each component. This commit introduces a `TypeCheckScopes` class that is responsible for flattening directives and computing the scope per NgModule. It caches the computed results as appropriate to avoid repeated computation.
JoostK
added
action: merge
The PR is ready for merge by the caretaker
target: patch
This PR is targeted for the next patch release
area: compiler
Issues related to `ngc`, Angular's template compiler
labels
Sep 8, 2020
atscott
approved these changes
Sep 8, 2020
atscott
pushed a commit
that referenced
this pull request
Sep 8, 2020
…#38749) For the compilation of a component, the compiler has to prepare some information about the directives and pipes that are used in the template. This information includes an expression for directives/pipes, for usage within the compilation output. For large NgModule compilation scopes this has shown to introduce a performance hotspot, as the generation of expressions is quite expensive. This commit reduces the performance overhead by only generating expressions for the directives/pipes that are actually used within the template, significantly cutting down on the compiler's resolve phase. PR Close #38749
atscott
pushed a commit
that referenced
this pull request
Sep 8, 2020
…ion (#38749) When type-checking a component, the declaring NgModule scope is used to create a directive matcher that contains flattened directive metadata, i.e. the metadata of a directive and its base classes. This computation is done for all components, whereas the type-check scope is constant per NgModule. Additionally, the flattening of metadata is constant per directive instance so doesn't necessarily have to be recomputed for each component. This commit introduces a `TypeCheckScopes` class that is responsible for flattening directives and computing the scope per NgModule. It caches the computed results as appropriate to avoid repeated computation. PR Close #38749
atscott
added a commit
to atscott/angular
that referenced
this pull request
Sep 9, 2020
…information (angular#38749)" This reverts commit e156e29. internal failure: https://test.corp.google.com/ui#id=OCL:329948619:BASE:329967516:1599160428139:d63165ae
atscott
added a commit
to atscott/angular
that referenced
this pull request
Sep 9, 2020
…are used (angular#38749)" This reverts commit 775c305. internal failure: https://test.corp.google.com/ui#id=OCL:329948619:BASE:329967516:1599160428139:d63165ae
atscott
added a commit
that referenced
this pull request
Sep 9, 2020
…information (#38749)" (#38767) This reverts commit e156e29. internal failure: https://test.corp.google.com/ui#id=OCL:329948619:BASE:329967516:1599160428139:d63165ae PR Close #38767
atscott
added a commit
that referenced
this pull request
Sep 9, 2020
…are used (#38749)" (#38767) This reverts commit 775c305. internal failure: https://test.corp.google.com/ui#id=OCL:329948619:BASE:329967516:1599160428139:d63165ae PR Close #38767
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
area: compiler
Issues related to `ngc`, Angular's template compiler
cla: yes
target: patch
This PR is targeted for the next patch release
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.
Cherry-pick of commits from #38539