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

Use mergeFast in a hotspot #9654

Closed
wants to merge 2 commits into from
Closed

Conversation

rigdern
Copy link
Contributor

@rigdern rigdern commented Aug 30, 2016

In profiling our app, we found that the usage
of merge in Text.js was showing up as a
hotspot. We've replaced this usage of merge
with mergeFast.

Test plan (required)

This change is used in my team's app.

Adam Comella
Microsoft Corp.

In profiling our app, we found that the usage
of `merge` in `Text.js` was showing up as a
hotspot. We've replaced this usage of `merge`
with `mergeFast`.

We've also updated `mergeFast` to use `merge`
in dev mode so that developers can benefit
from the extra validation it does on its
arguments.
@ghost
Copy link

ghost commented Aug 30, 2016

By analyzing the blame information on this pull request, we identified @JoelMarcey and @MattFoley to be potential reviewers.

@ghost ghost added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Aug 30, 2016
@MattFoley
Copy link

MattFoley commented Aug 31, 2016

This is the first time I've been poked by Github bot, but this change looks good to me.

The only suggestion I would have is to use let or even better const, rather than var, but I don't know RN's policy on using ES6 syntax in the main repo. (They may want to not for now, as it takes some specific babel plugins.)

@ide
Copy link
Contributor

ide commented Aug 31, 2016

merge(a, b) and mergeFast(a, b) aren't guaranteed to be the same for all (a, b), which is concerning since merge(a, b) is run in__DEV__ but not production. Keeping dev and production the same as much as possible is one of the best ways to head off bugs.

It would be better either to use mergeFast in all environments or write a new helper function like mergeOwnPropertiesFast with the same semantics as merge by doing hasOwnProperty checks or iterating over Object.keys, whichever's faster.

As per @ide's suggestion, mergeFast should behave the same in dev and production.
@rigdern
Copy link
Contributor Author

rigdern commented Aug 31, 2016

@ide you make a good point about dev vs production. I updated my PR to use mergeFast in all environments.

@ghost
Copy link

ghost commented Aug 31, 2016

@rigdern updated the pull request - view changes

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2016
@ide
Copy link
Contributor

ide commented Aug 31, 2016

@facebook-github-bot shipit

@ghost ghost added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Aug 31, 2016
@ghost
Copy link

ghost commented Aug 31, 2016

Thanks for importing. If you are an FB employee go to Phabricator to review internal test results.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2016
@ghost ghost closed this in 5d7227a Sep 1, 2016
@rigdern rigdern deleted the rigdern/mergeFast branch September 1, 2016 21:54
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. p: Microsoft Partner: Microsoft Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants