-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Explore scrolling performance issues #569
Comments
Did you measure a specific performance issue? Why does it matter how many time it rerenders? |
Ok, I've updated the demo to include 900 rows. Run it, open Devtools in clean browser, set cpu slowdown to 6x, and run the profiler. I'm getting: Animation Frame Fired I'm not a performance expert, so I may well be misinterpreting this. Come to think of it, I wonder if this is simply a case of needing the row virtualization. Edit: Oh, and I disabled whyDidYouRender for profiling since it looks like it adds significantly to the apparent slowness. |
I think I'm facing the same issue. The grid I have has 87 rows with 15 columns for a total of 1260 cells. It seems that scrolling horizontally re-renders all the cells while scrolling vertically doesn't. It also seems that all columns are rendered five times when the grid is first rendered slowing it down. Changing Setting |
@ognjenio do you have a codesandbox? |
It was already late last night, so here it is: https://codesandbox.io/s/awesome-black-b812m |
@ognjenio Thanks. I have further simplified the reproduction down to: https://codesandbox.io/s/infallible-archimedes-339tz, deployed to production: https://csb-339tz.netlify.app/. The latter performs better. However, It seems that TextField is simply too slow for this use case. |
Just FYI we replaced the TextField with a div with However, once the number of rows increased to ~2000 it once again became unusable so we've had to drop it. Luckily we discovered this early. |
@ognjenio with virtulization, the number of rows shouldn't matter. Do you have an example we can look into? |
It's the same thing but with more rows. Instead of having ~1200 cells as in the previous example, there are now ~60k cells. Scrolling vertically is still fine. But scrolling horizontally still renders all the cells. Even though now it's just a div (and not a TextField) it takes a while. Plus all the columns are being rendered five times on init, so it even takes a while for the grid to render in the first place. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi, we also have a issue with the DataGrid (Pro), while having a modal open to add a new row (Doctor) in our case, the datagrid re-renders about 15 times, while 1 frame is for our modal (changing a letter in a textfield). Is there any specific prop that should be memoized to avoid excesive re-rendering? Also, the rerender takes a long time, which caused the modal form field to feel extremely sluggish, without any simulation, on a Macbook Pro M1 / Firefox |
@Richard87 There may be some pointed advice from others, but having worked with the grid and re-rendering issues, have you tried the following:
All in all, the last statement has me wonder if it's at all feasible to avoid a re-render of every record when the js-array of records changes. If anyone has tricks to get around this, I look forward to learning how to do so myself. |
Still facing this issue, any idea how to resolve this? If we don't use renderCell , then it's pretty smooth. However have to use renderCell bcz of usability constriants. |
The issue is still there in v6-beta.0, although the behavior is a bit different. |
We're also having this issue when using renderCell to display some custom formatting for certain cells. We noticed a huge drop in grid performance once renderCell was added, even when it is just displaying the contents of the cell without custom formatting. |
@m4theushw We actually already tried implementing that change, but it didn't have any impact on performance. We're not populating the grid with a lot of rows so I don't think this is the issue. |
We are using DataGridPremium and I'm facing the same issue. On vertical scrolling, when the cell enters or leaves the viewport, it rerenders each cell. Even React.memo doesn't solved this issue. Edit: |
I have been able to observe performance issues with the example posted by @cherniavskii above, but the clear culprit is MUI But there might be other issues beyond the case specific to @benosmond or @tyukesz: Could you provide a runnable code example that displays the issue? |
I believe this error comes from |
From Core side, it really depends on the components that are used in the DataGrid. Using Going back to the issue on X side, what are the components used the most there? I am asking because we can try to optimize for these use cases. For e.g., we can try to avoid the time it takes to style the component by using the headless hook that Base UI provides and moving the styles up to the parent DataGrid component (similarly as it is done for example for the cells). This would be my general recommendation for any components that are rendered many times. In terms of how much performance gain we can do with this, we can use https://mui.com/system/getting-started/usage/#performance-tradeoffs - row c. is what is interesting for us. Note, we are currently looking for ways how we can improve the performance in terms of the styling solution, and we will likely go with some zero-runtime CSS-in-JS solution, which long term may help if the styling is the thing that takes most of the time. |
I checked our implementation and even though we weren't using For reference this is a grid with 50 records per page, and ~45 columns. |
@benosmond Do you have a reproducible test case? I am unable to observe the behavior. Ideally a codesandbox link. You can fork any codesandbox demo on the documentation to base your test case on. |
Issue with scrolling still persists, no custom components or renders, |
@akullpp Do you have a reproducible example I could inspect? Please open a new issue if it's related to a feature in particular (eg |
Never mind, it was my mistake. |
I've only just started using this component so I might be missing something, but it looks like there's a lot of unnecessary re-renders. The three I've split out are repeated many times, it looks like one repeat for every row, but I will test more.
Current Behaviour 😯
Expected Behaviour 🤔
Little to no re-renders
Steps to Reproduce 🕹
Using demo code for a basic Data Grid from the docs: https://codesandbox.io/s/material-ui-issue-forked-ni3nx
Open devtools console to see the output.
Context 🔦
Your Environment 🌎
The text was updated successfully, but these errors were encountered: