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(language-service): create StaticReflector once only #32543
Conversation
Need to rebase after #32098 is merged |
2a154b0
to
f1f7f6b
Compare
711222b
to
3fea08a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once it has been rebased.
3fea08a
to
4c1e2b1
Compare
if (!symbols) { | ||
return []; | ||
} | ||
this.symbolFromFile.delete(fileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a StaticSymbol[]
that is empty, this branch will still be hit right? Maybe we should do a check for undefined so that the file is still deleted from symbolFromFile
if not undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't quite get that.. The case of undefined is handled on line 186. If it's an empty array, it should still be deleted from the map, which is handled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad; I thought ![] === true
The creation of StaticReflector in createMetadataResolver() is a very expensive operation because it involves numerous module resolutions. To make matter worse, since the API of the Reflector does not provide the ability to invalidate its internal caches, it has to be destroyed and recreated on *every* program change. This has a HUGE impact on performance. This PR fixes this problem by carefully invalidating all StaticSymbols in a file that has changed, thereby reducing the overhead of recomputation on program change.
0886275
to
766964b
Compare
if (!symbols) { | ||
return []; | ||
} | ||
this.symbolFromFile.delete(fileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad; I thought ![] === true
merge-assistance: misko has global approval |
The creation of StaticReflector in createMetadataResolver() is a very expensive operation because it involves numerous module resolutions. To make matter worse, since the API of the Reflector does not provide the ability to invalidate its internal caches, it has to be destroyed and recreated on *every* program change. This has a HUGE impact on performance. This PR fixes this problem by carefully invalidating all StaticSymbols in a file that has changed, thereby reducing the overhead of recomputation on program change. PR Close angular#32543
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. |
The creation of
StaticReflector
increateMetadataResolver()
is a very expensive operation because it involves numerous module resolutions (on the order of hundreds) to initialize core Angular symbols.Since the API of the Reflector does not provide the ability to invalidate its internal caches,
StaticReflector
has to be destroyed and recreated on every program change.This has a HUGE impact on performance.
This PR fixes this problem by carefully invalidating all StaticSymbols in a file that has changed, thereby greatly reducing the overhead of recomputation on program change.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information