react-virtualized-tree icon indicating copy to clipboard operation
react-virtualized-tree copied to clipboard

Handling large number of children

Open ghost opened this issue 6 years ago • 10 comments

Hi,

I'm trying to render tree structures having largen numbers of direct children (several thousands). Rendering times are very slow then. I think the reason for this is the way getFlattenedTree is implemented.

ghost avatar Jan 23 '19 17:01 ghost

Hi @Baehn.

I believe the tree supports a reasonable number of child nodes, but yes the bottleneck is getFlattenedTree.

I will be releasing some news on a more performant approach over the next couple of days

diogofcunha avatar Jan 26 '19 15:01 diogofcunha

Hi @Baehn

Just did some work on this and by managing more state could make some fantastic improvements.

This work is still unstable, so it isn't available on npm just yet, will be in the next few days.

I change https://diogofcunha.github.io/react-virtualized-tree/#/examples/large-collection example to use this Unstable tree and it is rendering around 1.7 Million nodes and has you can see updates in the tree are really fast.

Hope this will help you.

diogofcunha avatar Jan 27 '19 00:01 diogofcunha

great! Have you tried trees with many direct childrens? I have changed the implementation of getFlattenedTree and the filtering method in FilteringContainer and got massive improvements. I replaced reduce with an simple recursion using an accumulator (I think the bottleneck is the creation and concat of arrays). If your are interested I can post my implementation here.

ghost avatar Feb 02 '19 13:02 ghost

@Baehn @diogofcunha from the ECMAScript 2015 document, reduce includes lots of unnecessary steps that we can skip to achieve better performance. So I'm totally agree we should rewrite it with simple for loop.

Ref: https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.reduce

Performance test can be found here: https://hackernoon.com/javascript-performance-test-for-vs-for-each-vs-map-reduce-filter-find-32c1113f19d7

hieuhlc avatar Feb 19 '19 08:02 hieuhlc

@diogofcunha may I ask what is the Unstable in UnstableFastTree, and when are we going to have it stable?

hieuhlc avatar Feb 19 '19 08:02 hieuhlc

Hi @Baehn.

I'm aware of performance implications with reduce, although most times it doesn't really matter.

The new tree implementation (Unstable) is written with for loops and an improved seek and it's much faster.

Yes, there will be a stable version, I just need to find the time to play around with it a little bit more and make sure it's good enough to ship.

diogofcunha avatar Feb 19 '19 09:02 diogofcunha

Any update on when UnstableFastTree will be on npm?

robintindale avatar Jul 30 '19 20:07 robintindale

I'm also interested in the stable version of UnstableFastTree 🙂 @diogofcunha Is there anything I can help you with?

maxnowack avatar Oct 23 '19 14:10 maxnowack

I see only exporting Tree and {selectors, renderers, constants, FilteringContainer} and so on. But UnstableFastTree is not yet, is this waiting for a stable version or how will I use it?

DawnL6 avatar Nov 06 '19 10:11 DawnL6

https://github.com/ngryman/tree-crawl

abhishiv avatar Feb 08 '20 06:02 abhishiv