-
Notifications
You must be signed in to change notification settings - Fork 49.3k
Description
We are running into some performance issues using React on the server side. In large component trees, we are finding that render time increases linearly. In our case, we are seeing render times over 80ms for a relatively simple page (112 components). During profiling we have found that the _bindAutoBindMethods
is showing up at the top of our trace:
ticks total nonlib name
245 0.6% 0.6% LazyCompile: ~L._bindAutoBindMethods /Volumes/Projects/app/node_modules/react/dist/react-with-addons.min.js:13
146 0.4% 0.4% LazyCompile: ~L.mountComponent /Volumes/Projects/app/node_modules/react/dist/react-with-addons.min.js:13
75 0.2% 0.2% LazyCompile: Join native array.js:119
72 0.2% 0.2% LazyCompile: bind native v8natives.js:1578
64 0.2% 0.2% LazyCompile: ~i.createElement /Volumes/Projects/app/node_modules/react/dist/react-with-addons.min.js:14
45 0.1% 0.1% Callback: execute
38 0.1% 0.1% LazyCompile: hasOwnProperty native v8natives.js:249
37 0.1% 0.1% LazyCompile: *parse native json.js:55
31 0.1% 0.1% LazyCompile: *n /Volumes/Projects/app/node_modules/react/dist/react-with-addons.min.js:16
I went in and added hrtime() calls inside _bindAutoBindMethods
to see how much time was contributing to the rendering, and found that over 23ms was used just within this method. This may not seem like a lot, but this has pretty dramatic effect on throughput when the server is rendering synchronously.
Is there a way to optimize this so that binding happens lazily? On the server, many of the methods may not even be called (event handlers, lifecycle events, getDOMNode
, etc.).