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

perf(core): make DI decorators tree-shakable when used in useFactory deps config #40145

Closed

Conversation

AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Dec 16, 2020

This commit updates the logic that calculates useFactory function arguments to avoid relying on instanceof
checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property).

Another perf benefit is having less megamorphic reads while calculating args for the useFactory call: we used to
check whether a token has ngMetadataName property 4 times (in worst case), now we have just 1 megamorphic read in
all cases.

Closes #40143.

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added area: performance state: WIP refactoring Issue that involves refactoring or code-cleanup area: core Issues related to the framework runtime target: minor This PR is targeted for the next minor release cross-cutting: tree-shaking labels Dec 16, 2020
@ngbot ngbot bot modified the milestone: Backlog Dec 16, 2020
@google-cla google-cla bot added the cla: yes label Dec 16, 2020
@ngbot ngbot bot modified the milestone: Backlog Dec 16, 2020
@AndrewKushnir
Copy link
Contributor Author

Related PR: #40122.

@AndrewKushnir
Copy link
Contributor Author

Presubmit.

@AndrewKushnir AndrewKushnir changed the title perf(core): make DI decorators tree-shakable when used for useFactory deps config perf(core): make DI decorators tree-shakable when used in useFactory deps config Dec 16, 2020
@AndrewKushnir AndrewKushnir force-pushed the di_decorators_tree_shaking branch 2 times, most recently from 0be3e77 to ae5904c Compare January 9, 2021 03:23
@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Jan 9, 2021
@AndrewKushnir AndrewKushnir marked this pull request as ready for review January 11, 2021 19:40
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty straightforward to me. LGTM.

…y` deps config

This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof`
checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property).

Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to
check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in
all cases.

Closes angular#40143.
@AndrewKushnir
Copy link
Contributor Author

Presubmit #3.

@@ -838,11 +838,11 @@ export declare interface RendererType2 {
}

export declare class ResolvedReflectiveFactory {
dependencies: ɵangular_packages_core_core_d[];
dependencies: ɵangular_packages_core_core_e[];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for public-api group reviewers: this change is a noop from public API perspective, this change is likely a result of some symbol reordering in generated bundle (since new logic was added as a part of this PR).

Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@pullapprove pullapprove bot requested a review from jelbourn January 13, 2021 16:55
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

@pullapprove pullapprove bot requested a review from IgorMinar January 13, 2021 17:45
@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 13, 2021
@AndrewKushnir AndrewKushnir removed the request for review from alxhub January 13, 2021 17:49
@pullapprove pullapprove bot requested a review from alxhub January 13, 2021 17:49
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker 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: presubmit The PR is in need of a google3 presubmit labels Jan 13, 2021
@AndrewKushnir
Copy link
Contributor Author

Merge assistance: please change the target label to "target: rc" if this PR is merged after v11.1.0-rc.0 is released (so that this change makes it into v11.1.0). Thank you.

@atscott atscott added target: rc This PR is targeted for the next release-candidate and removed target: minor This PR is targeted for the next minor release labels Jan 13, 2021
@atscott atscott closed this in 6cff877 Jan 13, 2021
atscott pushed a commit that referenced this pull request Jan 13, 2021
…y` deps config (#40145)

This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof`
checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property).

Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to
check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in
all cases.

Closes #40143.

PR Close #40145
@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 Feb 13, 2021
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: core Issues related to the framework runtime area: performance cla: yes cross-cutting: tree-shaking merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note refactoring Issue that involves refactoring or code-cleanup target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ivy: DI decorators tree-shaking when they are used to configure useFactory deps
6 participants