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] Fix performance issue when sorting columns #1368

Merged
merged 9 commits into from Apr 12, 2021

Conversation

dtassone
Copy link
Member

@dtassone dtassone commented Apr 6, 2021

fix #1330

@DanailH
Copy link
Member

DanailH commented Apr 7, 2021

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?
Maybe this is a bugger problem that needs to be looked at.

@oliviertassinari oliviertassinari changed the title [DataGrid] fix perf for sorting [DataGrid] Fix performance issue when sorting columns Apr 8, 2021
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! performance labels Apr 8, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The performance regression is definitely fixed 👍
  2. 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?
  3. 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

Screenshot 2021-04-08 at 12 39 14

  • the above fix bypass the DOM read.

@dtassone
Copy link
Member Author

dtassone commented Apr 8, 2021

perf is subject to the browser engine so it varies with browsers.

@oliviertassinari
Copy link
Member

perf is subject to the browser engine so it varies with browsers.

I have tried something, please review

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@dtassone dtassone closed this Apr 12, 2021
@dtassone dtassone reopened this Apr 12, 2021
@dtassone dtassone merged commit edd4280 into mui:master Apr 12, 2021
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[XGrid] Sorting completly freeze
3 participants