Skip to content

perf(compiler-cli): cache source file for reporting type-checking diagnostics#47471

Closed
JoostK wants to merge 1 commit intoangular:mainfrom
JoostK:ngtsc/ttc/cache-template-sf
Closed

perf(compiler-cli): cache source file for reporting type-checking diagnostics#47471
JoostK wants to merge 1 commit intoangular:mainfrom
JoostK:ngtsc/ttc/cache-template-sf

Conversation

@JoostK
Copy link
Member

@JoostK JoostK commented Sep 18, 2022

When reporting type-checking diagnostics in external templates we create a ts.SourceFile of the template text, as this is needed to report Angular template diagnostics using TypeScript's diagnostics infrastructure. Each reported diagnostic would create its own ts.SourceFile, resulting in repeatedly parsing of the template text and potentially high memory usage if the template is large and there are many diagnostics reported. This commit caches the parsed template in the template mapping, such that all reported diagnostics get to reuse the same ts.SourceFile.

Closes #47470

@JoostK JoostK added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler compiler: template type-checking labels Sep 18, 2022
@ngbot ngbot bot modified the milestone: Backlog Sep 18, 2022
@JoostK JoostK marked this pull request as ready for review September 18, 2022 13:37
@JoostK JoostK force-pushed the ngtsc/ttc/cache-template-sf branch from 6211b4e to e73ea93 Compare September 20, 2022 17:19
@angular-robot angular-robot bot requested a review from alxhub September 20, 2022 17:19
…gnostics

When reporting type-checking diagnostics in external templates we create a
`ts.SourceFile` of the template text, as this is needed to report Angular
template diagnostics using TypeScript's diagnostics infrastructure. Each
reported diagnostic would create its own `ts.SourceFile`, resulting in
repeatedly parsing of the template text and potentially high memory usage
if the template is large and there are many diagnostics reported. This commit
caches the parsed template in the template mapping, such that all reported
diagnostics get to reuse the same `ts.SourceFile`.

Closes angular#47470
@JoostK JoostK force-pushed the ngtsc/ttc/cache-template-sf branch from e73ea93 to 289e7f5 Compare September 20, 2022 17:20
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 20, 2022
@JoostK
Copy link
Member Author

JoostK commented Sep 21, 2022

merge-assistance: this needs reapproval for a post-review fixup.

@pkozlowski-opensource pkozlowski-opensource removed the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Sep 21, 2022
@pkozlowski-opensource
Copy link
Member

@JoostK it doesn't merge cleanly to a patch branch. I'm going to re-label it as minor but could you open a separate PR for the patch branch?

@pkozlowski-opensource pkozlowski-opensource added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Sep 21, 2022
@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit 8fcadaa.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 22, 2022
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 action: presubmit The PR is in need of a google3 presubmit area: compiler Issues related to `ngc`, Angular's template compiler compiler: template type-checking target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OptionalChainNotNullableCheck causes heap out of memory error

3 participants