Some steps I'm taking to debug bad performance with reselect.
My performance problems are coming from the fact that I am not using reselect properly. I wrote a bunch of selectors that use props but don't do anything to make sure they can be shared across multiple components.
The fix for this is: https://github.com/reactjs/reselect/blob/fec65b63b9a2ffa570348271138d20cf831e0185/README.md#sharing-selectors-with-props-across-multiple-components.
But before rewriting tons of code, I'd like to see which selectors are recomputed the most.
https://github.com/garbles/why-did-you-update
-
Use https://github.com/ordoro/babel-transform-reselect-selector-name
-
Update the reselect code to accept name as the first argument and to log it. See the
reselect.js
code below. Use babelify and overwritenode_modules/reselect/lib/index.js
. -
Log selector recomputations
table = SelectorRegistry.map(selector => [selector.id, selector.recomputations()]).filter(x => x[1] > 0).sort((a,b) => a[1] - b[1]); table.length && console.table(table); SelectorRegistry.map(selector => selector.resetRecomputations());
- Update babelrc to contain
/Users/luqmaan/dev/babel-reselect-name-transform/lib/index.js