Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Performance: data grid spends about half the time sorting and filtering even though the features are disabled #11910

Open
scamden opened this issue Feb 2, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature feature: Sorting Related to the data grid Sorting feature performance

Comments

@scamden
Copy link

scamden commented Feb 2, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/datagrid-huge-tree-shared-with-mui-forked-lf9gz3

Steps:

  1. Start perf trace
  2. Mount the grid
  3. Sto the trace

Current behavior

About half the time is spent filtering and sorting despite it being disabled
Screenshot 2024-02-01 at 4 01 55 PM

Expected behavior

no time is spent sorting or filtering when it's disabled

Context

Increase performance on a very large data grid

Your environment

npx @mui/envinfo
System:
    OS: macOS 14.3
  Binaries:
    Node: 18.12.1 - ~/.nodenv/versions/18.12.1/bin/node
    npm: 8.5.1 - ~/.nodenv/versions/18.12.1/bin/npm
    pnpm: 8.14.1 - ~/.nodenv/versions/18.12.1/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.139
    Edge: Not Found
    Safari: 17.3
  npmPackages:
    @emotion/react:  11.9.3
    @emotion/styled:  11.9.3
    @mui/base:  5.0.0-alpha.87
    @mui/core-downloads-tracker:  5.14.18
    @mui/icons-material:  5.14.18
    @mui/lab:  5.0.0-alpha.88
    @mui/material:  5.14.18
    @mui/private-theming:  5.14.18
    @mui/styled-engine:  5.14.18
    @mui/styles:  5.14.18
    @mui/system:  5.14.18
    @mui/types:  7.2.9
    @mui/utils:  5.14.18
    @mui/x-data-grid:  6.19.2
    @mui/x-data-grid-premium:  6.19.2
    @mui/x-data-grid-pro:  6.19.2
    @mui/x-date-pickers:  5.0.8
    @mui/x-date-pickers-pro:  5.0.20
    @mui/x-license-pro:  5.13.1
    @types/react:  18.0.18
    react:  18.2.0
    react-dom:  18.2.0
    typescript: 5.3.2 => 5.3.2

Search keywords: performance data filter sort
Order ID: 77647

@scamden scamden added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 2, 2024
@oliviertassinari oliviertassinari added performance component: data grid This is the name of the generic UI component, not the React module! labels Feb 4, 2024
@michelengelen michelengelen changed the title Performance: data grid spends about half the time sorting and filtering even though the features are disabled [data grid] Performance: data grid spends about half the time sorting and filtering even though the features are disabled Feb 5, 2024
@michelengelen michelengelen added feature: Filtering Related to the data grid Filtering feature feature: Sorting Related to the data grid Sorting feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 5, 2024
@michelengelen
Copy link
Member

Thanks @scamden for reporting this ... I have put it on our board for the team to have a look!

@romgrk
Copy link
Contributor

romgrk commented Feb 8, 2024

The disableXxxx flags aren't meant to fully disable a feature, they fullfill the same role as the input[disabled] attribute: the feature is UI disabled only, but still present. All the grid flags are going to be UI-disable only, this is being clarified in v7.

However, we should be able to avoid the performance cost in some cases.

For filtering, we can avoid filtering if:

  • Filtering mode is "client"
  • Filter model items is empty
  • Filter model quickValues is empty

One issue we have though is that we create a filteredRowsLookup which has the structure { [id: GridRowId]: boolean | undefined }, and we set the value to true for all rows. So we have a cost that scales as O(n). Some of this could be avoided by the work in #10068 I think. We should probably also have a special Set value that allows us to encode "everything" without having to explicitly set each value, it would save runtime & memory costs. Something like this:

enum RowSet {
  All,
  Some(Set<GridRowId>)
}

For sorting, I have no idea what can be done, I haven't touched that part of the codebase yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature feature: Sorting Related to the data grid Sorting feature performance
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

4 participants