-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: separate row cleanup #12023
Conversation
Deploy preview: https://deploy-preview-12023--material-ui-x.netlify.app/ |
removalList.nodes.at(0)!.start + CLEANUP_ROWS, | ||
); | ||
} else { | ||
removalList.keep(removalList.nodes.at(0)!.end - CLEANUP_ROWS, removalList.nodes.at(0)!.end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index should be -1
, not 0
packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualization.tsx
Outdated
Show resolved
Hide resolved
export function useIdleCallback() { | ||
return useLazyRef(createIdleCallback).current; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unmount cleanup logic?
Co-authored-by: Olivier Tassinari <[email protected]> Signed-off-by: Rom Grk <[email protected]>
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I've finished implementing the cleanup logic, here is a quick performance comparison. The new implementation does its cleanup after 1s without user interaction. Kooha-2024-02-22-23-04-28.webm |
@romgrk When I run #11866 (comment), the benchmark, and UX is noticeably worse on this PR. Not sure it's working 😁 |
Weird results, this PR makes it smoother for me. Any chance you can send me a recording and a profile of the benchmark? (the "Save profile..." button in the Performance tab) |
@romgrk I can reproduce this as well. It gets slower the more you scroll: https://next--material-ui-x.netlify.app/x/react-data-grid/#pro-plan Screen.Recording.2024-02-26.at.12.46.20.movhttps://deploy-preview-12023--material-ui-x.netlify.app/x/react-data-grid/#pro-plan Screen.Recording.2024-02-26.at.12.46.49.movHere's the profile: https://drive.google.com/file/d/1in_kUcfi9s4_zv06mobVPAPNsXjCzPTT/view?usp=drive_link |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I WAS WRONG. Anyway long story short I have a benchmarking chrome user-profile that is usually clean (no react-dev-tools extension or anything else that affects runtime performance) so I can benchmark precisely. Well I had activated the devtools experimental flag There's a few other performance improvements on this PR that I'll pick up separately. |
@romgrk maybe worth reporting as crbug? I'm not sure if it's expected that removeChild becomes slower with invalidation tracking enabled |
Stacked on #12013 and #12019 to explore #11866
Experiment with scrolling performance.
The idea behind this is that most of our scroll event callback runtime is spent removing DOM nodes, while appending new ones is much less expensive. This is a characteristic of the DOM spec and outside of our control. The graph below shows the amount of time spent adding new rows (green) and removing old rows (red). Other virtualized grids such as AG-grid have the same performance profile. The goal here is to try to remove the red section from the
flushSync
path, and try to pay that cost at a different moment, possibly withrequestIdleCallback
.Before: https://next.mui.com/x/react-data-grid/virtualization/#column-virtualization
After: https://deploy-preview-12023--material-ui-x.netlify.app/x/react-data-grid/virtualization/#column-virtualization
Changes
RowIntervalList
, an interval list data structure that holds row indexes and their render context.colSpan
computations in scroll event, those are very expensive and unnecessary unless there is a.colSpan
somewhereposition: absolute; top: ...
positioned.