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 set changing prop #32574

Conversation

@pkozlowski-opensource
Copy link
Member

commented Sep 10, 2019

This PR introduces a new benchmark that focuses on performance of property updates. It also contain a fix where by removing a megamorphic access we can speed up this new benchmark by ~30%.

Review commit by commit and check individual commit message for more details.

@googlebot

This comment has been minimized.

Copy link

commented Sep 10, 2019

☹️ Sorry, but only Googlers may change the label cla: yes.

@googlebot googlebot added the cla: yes label Sep 10, 2019
@ngbot ngbot bot added this to the needsTriage milestone Sep 10, 2019
@pkozlowski-opensource pkozlowski-opensource force-pushed the pkozlowski-opensource:perf_set_changing_prop branch from f1cca3a to db8701e Sep 10, 2019
While determining a property name to bind to we were checking a mapping object
resulting in the megamorphic read. Replacing such read with a series of if checks
speeds up rproprty update benchmark ~30% (~1400ms down to ~1000ms).
@pkozlowski-opensource pkozlowski-opensource marked this pull request as ready for review Sep 10, 2019
@pkozlowski-opensource pkozlowski-opensource requested a review from angular/fw-core as a code owner Sep 10, 2019
@kara
kara approved these changes Sep 10, 2019
Copy link
Contributor

left a comment

LGTM

*
* Performance note: this function is written as a series of if checks (instead of, say, a property
* object lookup) for performance reasons - the series of `if` checks seems to be the fastest way of
* mapping property names. Do NOT change without benchmarking.

This comment has been minimized.

Copy link
@kara

kara Sep 10, 2019

Contributor

👍

'tabindex': 'tabIndex',
};
function mapPropName(name: string): string {
if (name === 'class') return 'className';

This comment has been minimized.

Copy link
@mhevery

mhevery Sep 10, 2019

Member

I wonder if we could make this even faster if we did something like this:

const ch = name.charCodeAt(0);
if (ch === 99 /*c*/ || ch === 102 /*f*/' || ch === 105 /*i*/ || ch === 116 /*t*/ || ch === 't') {
  ...
}
@matsko

This comment has been minimized.

@matsko matsko closed this in ea378a9 Sep 12, 2019
matsko added a commit that referenced this pull request Sep 12, 2019
While determining a property name to bind to we were checking a mapping object
resulting in the megamorphic read. Replacing such read with a series of if checks
speeds up rproprty update benchmark ~30% (~1400ms down to ~1000ms).

PR Close #32574
arnehoek added a commit to arnehoek/angular that referenced this pull request Sep 26, 2019
arnehoek added a commit to arnehoek/angular that referenced this pull request Sep 26, 2019
…2574)

While determining a property name to bind to we were checking a mapping object
resulting in the megamorphic read. Replacing such read with a series of if checks
speeds up rproprty update benchmark ~30% (~1400ms down to ~1000ms).

PR Close angular#32574
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

commented Oct 13, 2019

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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.