-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Reduce React load time by 3-7ms in Node #7493
Conversation
Works for me, thanks! |
Nuclide is not even using React.DOM :( https://fburl.com/407417521 |
If you remove mapObject from this test, you can also kill the entire module from React codebase fyi: react/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js Line 166 in 484f96b
|
Thanks! EDIT: I misread as |
Would we be willing to use memoizing lazy getters instead? I suspect very few of these tags are used, in practice. |
I just ran a quick unscientific test, and it takes ~0.63ms to create var ReactDOMFactories = {
get a() { return createDOMFactory('a'); },
get abbr() { return createDOMFactory('abbr'); },
//...
}; It takes ~0.13ms to create that object. I'm not sure if ~0.5ms is worth it. |
Yea not worth it. We're 100% more likely to do #6169 and split these off from React entirely. |
Awesome work. |
(cherry picked from commit e5f9ae2)
The creation of the DOM factories with
mapObject
is a relatively expensive operation in Node. It's accounting for ~10% of therequire
load time across the various builds. I saw some improvements from only unwrappingcreateDOMFactory
, but the bulk of the gains are from removingmapObject
.I ran a few benchmarks that only focused on load times using node@6.3.1 and jsc@11601.7.2 (source). Each test was run 100 times:
This change also reduced the gziped size of the bundles:
Raw size can also be reduced by renaming
createDOMFactory
to something shorter.This change is GCC safe (see discussion in #5759).
I'm also investigating adding a babel transform to inline the result of
keyMirror
andkeyOf
.