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] Fix performance issue when sorting columns #1368
Conversation
The fix is working but it is still the thread freezes for a couple of seconds before the sorting finishes. Maybe we can add a loader to indicate that something is happening? But either way, the end-user should be able to perform other actions on the page while the sorting is happening, no? |
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.
- The performance regression is definitely fixed 👍
- It seems that we might have the opportunity to add a test case here. As far as I remember, it's the second time we break the performance of the sorting (or unless it was the checkbox selection only last time 🤔). Maybe we could render one grid with 1,000 rows, sort it and assert the time it took is x10 below a threshold that HEAD would break?
- Please take the time to detail each pull request. I have dove into the issue to understand and explain what went wrong, to see if there is something we can learn, for the whole team, in the future.
The current issue is in the following call order:
- sorting trigger
- each row calls
api.getCellParams
- which calls
getBaseCellParams
- which calls
getCellElement
- which calls
x.querySelector(y)
=> really slow
- the above fix bypass the DOM read.
perf is subject to the browser engine so it varies with browsers. |
c8f6000
to
24a6bb2
Compare
24a6bb2
to
d0a7b54
Compare
I have tried something, please review |
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
await waitFor(() => expect(document.querySelector('.MuiDataGrid-sortIcon')).to.not.be.null); | ||
const t1 = performance.now(); | ||
const time = Math.round(t1 - t0); | ||
expect(time).to.be.lessThan(200); |
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.
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.
Yes we can increase the limit and add an acceptable buffer.
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.
fix #1330