Datagrid: interruptable & incremental filtering #10239
Replies: 2 comments 3 replies
-
What's the size of a dataset that measurably benefits from these optimisations? I'm personally yet to come across a dataset where filtering gets noticably slow with our home built filtering system that we've integrated with MUI datagrid. So,I'm wondering if there are lower hanging fruits for you to optimise than parallelisation that would benefit most(?) of the users without incurring costs on complexity/maintainability, extensibilty and bundle size. |
Beta Was this translation helpful? Give feedback.
-
Thank you for putting this up! Interruptable filtering sounds interesting indeed 🙂 I wonder what improvements this can bring for the end users. |
Beta Was this translation helpful? Give feedback.
-
This discussion summarizes the options for adding those two capabilities. Interruptable filtering allows to cancel a computation if the current filter is canceled by the user (e.g. by typing more characters), while incremental filtering allows to return partial results before the full computation is completed (e.g. to allow rendering the first N results as soon as possible, which makes the filtering feel basically instant, where N can be defined as the amound of visible rows).
Acquiring those capabilities means implementing either a concurrent solution (on the main thread) or a parallel solution (on a web worker thread). Both of them mean that our filtering interface becomes asynchronous.
Solutions
Concurency
A concurrent solution would be to split the filtering work in small batches and compute them one at a time, delaying the rest for a certain delay if the computation takes too long to run. This is the same technique used by React for rendering. The advantage is that there is no data copy. However, we don't get access to React scheduler (ignoring
react.__secret_internals_do_not_use_or_you_will_be_fired
which is obviously not meant to be public), so the filtering would be competing for the CPU with React.Parallelism
A parallel solution would be to filter the data in a web worker thread. The advantage is that we can use more than one core and don't have any scheduling problems. The disadvantage is that we need to make a copy of the full dataset to allow filtering it.
A possible way to avoid having 2 full copies would be to treat web-worker threads the same way we treat server-side filtering, and the full data would live only in the web-worker thread. Implemented properly, this could give very good results.
Other notes
If we can also make our filtering more modular, we could also allow replacing parts of it easily, to allow for things like WASM-powered filtering.
Please leave your comments.
Beta Was this translation helpful? Give feedback.
All reactions