table icon indicating copy to clipboard operation
table copied to clipboard

Tables are really really slow..

Open NickyYo opened this issue 8 years ago • 2 comments

I'm rendering tables with around 50 columns and 70 rows and the table is crazy slow to render... when resizing columns there is even a few second delay.. The whole table and it's data structure is being re-rendered every-time a prop changes..

I mean whats this https://github.com/react-tools/react-table/blob/cdf806b3f6e1afb679ddfe329d02e9febf892518/src/utils.js#L98-L111

and this https://github.com/react-tools/react-table/blob/f74ba3cc1609f9f6b5e79e3f916b49d2b4bb22c4/src/lifecycle.js#L20-L23

JSON.stringify() for comparisons is really really bad, for example this is how it benchmarks against Lodash _.isEqual() http://jsben.ch/iv7bb

I'm going to send some pull requests as improvements but before I do so, am i wrong?

NickyYo avatar Jan 09 '18 14:01 NickyYo

Yes, JSON.stringify is much slower than a recursive early-out algo like _.isEqual, but in this case it was the most lightweight solution for the least effort. Also, given that it's only being used to clone/compare extremely small and shallow objects, this should be the least of your worries for table speed (I feel there are many other areas that could be improved before this one).

However, if you feel the urge to refactor clone() out of the comparison logic with an isEqual, you are more than welcome to do that! I will accept the PR as long as it does not use lodash. The reason for this is library size; even the smallest es6, tree shakeable imports from lodash result in massive amounts of inner-dependencies within the library, so you usually bring in at least 2 - 4 kb for even just one method. My expectations though for refactoring to our own isEqual method would be something around ~10 lines in a recursive function. If you want help let me know!

tannerlinsley avatar Jan 09 '18 17:01 tannerlinsley

Closing for now, feel free to reopen!

tannerlinsley avatar Jan 16 '18 20:01 tannerlinsley