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

[DataGrid] Improve vertical scrolling performance #11866

Closed
cherniavskii opened this issue Jan 30, 2024 · 2 comments · Fixed by #12019
Closed

[DataGrid] Improve vertical scrolling performance #11866

cherniavskii opened this issue Jan 30, 2024 · 2 comments · Fixed by #12019
Assignees
Labels
component: data grid This is the name of the generic UI component, not the React module! performance priority: important This change can make a difference regression A bug, but worse v7.x

Comments

@cherniavskii
Copy link
Member

cherniavskii commented Jan 30, 2024

The Sticky headers PR fixed a bunch of issues, improved horizontal scrolling UX, and reduced the gaps when dragging the scroll thumb.

However, the vertical scroll performance has regressed - see #10059 (comment)

We can improve the performance according to #10059 (comment):

I think it will be fairly easy to add a wrapping container for the cells and apply the style once. That in conjunction with the CSS contain: strict style should make it much more easy for the browser to layout stuff.

Search keywords:

@cherniavskii cherniavskii added performance component: data grid This is the name of the generic UI component, not the React module! regression A bug, but worse v7.x labels Jan 30, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jan 30, 2024
@cherniavskii cherniavskii moved this from 🆕 Needs refinement to 🔖 Ready in MUI X Data Grid Jan 30, 2024
@oliviertassinari oliviertassinari added the priority: important This change can make a difference label Feb 4, 2024

This comment was marked as resolved.

@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 26, 2024

@romgrk A quick progress report on my laptop, using this script to scroll

expand
class Scroller {
    static scroll({ element, distance = 50000, speed = 50, maxSpeed = 1000, acceleration = 0, callback, scrollFn }) {
        let scrollTop = 0;

        const intervalId = setInterval(() => {
            if (scrollFn) {
                scrollFn(scrollTop)
            } else {
                element.scrollTop = scrollTop;
            }

            scrollTop += speed;

            if (speed < maxSpeed) speed += acceleration;

            if (scrollTop > distance) {
                clearInterval(intervalId);
                callback && callback();
            }
        }, 5);
    }
}
Scroller.scroll({ element: document.querySelectorAll('.MuiDataGrid-virtualScroller')[1] })

Before https://deploy-preview-11650--material-ui-x.netlify.app/x/react-data-grid/#pro-plan

SCR-20240226-cuia

After #10059 (add position: sticky) https://deploy-preview-10059--material-ui-x.netlify.app/x/react-data-grid/#pro-plan

SCR-20240226-cumr

Today on HEAD https://next--material-ui-x.netlify.app/x/react-data-grid/#pro-plan

SCR-20240226-cvao

AG Grid https://www.ag-grid.com/example/, scrolling at the same speed and with the same number of column / column type

SCR-20240226-cwww

I confirm the regression is pretty much gone, nice job 👍.


As for future improvement opportunities, the ones I can see:

  1. Being smarter with the overscan, it feels like this [DataGrid] Performance: Improve virtualization overscan logic #11344 would have the most impact.

  2. The time we spend rendering Emotion styles. We might be able to save 50ms We should likely memo that: [data grid] Time spend rendering Emotion/Pigment CSS #12401

SCR-20240226-cywd
  1. Adding a translate3d on each row seems to save 30ms of Painting time, while it costs 20ms of Layout time, saving 10ms. [data grid] position: absolute for rows to avoid repaint #12399 This is because it avoids all the rows to repaint:
Screen.Recording.2024-02-26.at.02.27.30.mov

I guess positioning each row position: absolute could have an even better impact, avoiding a Paint when a row is added or removed to the list but without the Layout overhead cost.

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! performance priority: important This change can make a difference regression A bug, but worse v7.x
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants