constelation / monorepo

Mono repo for constelation's Components, functions, and CONSTANTS
https://constelation.github.io/monorepo/
MIT License
12 stars 3 forks source link

perf enhancements #9

Open kylpo opened 7 years ago

kylpo commented 7 years ago

Perf is better now that we are using Glamor, but it could be better. See Glamor's implementation of https://github.com/kylpo/glamor/blob/master/src/jsxstyle.js for a faster implementation of what we're doing with View, Style_, etc.

kylpo commented 7 years ago

Also consider using node-based benchmarking.

Reactjs - Speed up Server Side Rendering - Sasha Aickin - YouTube Great talk on 5 rules to speed up react: including using es6’s class instead of createClass

react-server-perf-tricks/benchmarkedFns.js at stage-6 · aickin/react-server-perf-tricks How he benchmarked

kylpo commented 7 years ago

Consider merging props without key iteration details at http://techblog.netflix.com/2017/01/crafting-high-performance-tv-user.html

kylpo commented 7 years ago

shallowCompare props in cwrp. Store props in state so that renders are as simple as possible. e.g.

export class Style_ extends React.Component<IProps, void> {
  componentWillReceiveProps(nextProps) {
    //... shallowcompare non-child props
  }
  render() {
    return React.cloneElement(Child, this.state)
  }
}

for web, just store the className returned by glamor, not the whole object of individual props.

Essentially hoists style to the instance level. Note, can't do module level because everything is defined as a prop in a render. spredfast/babel-plugin-transform-hoist-jsx-style: Hoist pure objects passed to 'style' prop hoists to module level.

kylpo commented 7 years ago

Use crysislinux/chrome-react-perf: An Operation Interface for react-addons-perf Package

kylpo commented 7 years ago

Remove Spread operator where possible, or ensure that it is the only thing passed in to avoid object.assigns.

Maybe just remove it completely because it depots https://babeljs.io/docs/plugins/transform-react-inline-elements/ and https://babeljs.io/docs/plugins/transform-react-constant-elements/