Skip to content

Conversation

toerndev
Copy link

This PR makes FlatTree support large data sets with good performance as long as most items are not rendered at once, which should be the common case.

This is done by optimizing two key functions.

The first deals with multiselect state, and simply batches all updates instead of calling ImmutableMap.set() in a loop over the entire subtree, which had a big performance impact due to each call copying the entire Map.
When toggling the checkbox for a branch with a 2800 item subtree, the delay went from an unusable 1800 ms to 8 ms.

The second fix is to avoid processing of invisible subtrees when generating the visible tree based on open items.
This one requires a larger tree to be noticeable, but at 35k items, the generator took 600 ms before and 10 ms after the fix.

An easy way to test is to modify the story "TreeSelection", changing the items array so that it's generated with a loop.

@toerndev toerndev force-pushed the master branch 3 times, most recently from 2629ffc to 5254266 Compare September 24, 2025 07:20
This PR makes FlatTree support large data sets with good performance as
long as most items are not rendered at once, which should be the common
case.

This is done by optimizing two key functions.

The first deals with multiselect state, and simply batches all updates
instead of calling `ImmutableMap.set()` in a loop over the entire
subtree, which had a big performance impact due to each call copying
the entire Map.
When toggling the checkbox for a branch with a 2800 item subtree, the
delay went from an unusable 1800 ms to 8 ms.

The second fix is to avoid processing of invisible subtrees when
generating the visible tree based on open items.
This one requires a larger tree to be noticeable, but at 35k items, the
generator took 600 ms before and 10 ms after the fix.

An easy way to test is to modify the story "TreeSelection", changing the
`items` array so that it's generated with a loop.
@toerndev
Copy link
Author

@microsoft-github-policy-service agree

@toerndev toerndev marked this pull request as ready for review September 24, 2025 07:27
@toerndev toerndev requested a review from a team as a code owner September 24, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant