-
Notifications
You must be signed in to change notification settings - Fork 843
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
Perf: EuiDataGrid don't recreate columns on every change #2676
Conversation
@@ -60,7 +60,7 @@ const columns = [ | |||
|
|||
const raw_data = []; | |||
|
|||
for (let i = 1; i < 100; i++) { | |||
for (let i = 1; i < 500; i++) { |
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.
We do accept that kind of size in Kibana so maybe it's worth to add it here?
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.
You could always make this dynamic through state, and let the user define it in the docs. The reason I kept it low was that I cared more about the docs page being snappy, then checking the performance of the grid itself. But now that you've made these changes it's a less a concern.
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.
I think you're right! The initial load time doesn't change so it's worth to lower it. Thank you for this comment!
columnId => | ||
availableColumns.find( | ||
({ id }) => id === columnId | ||
) as EuiDataGridColumn // cast to avoid `undefined`, it filters those out next |
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.
Why not filter first?
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.
I think (although I am not sure, I just wrapped it with useMemo
but that's how I understand the comment) that the find
returns nulls in case it won't find the id === columnId
and after that we're getting rid of the nulls with filter
🤔
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.
Indeed, this looks like whitespace-only changes with the additional useMemo
wrapping. I set originally set it up to filter second. No real reason, didn't occur to me to filter first 🤷♀
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.
Changes LGTM! Played with this locally, love the snappiness!
CI failure is a flaky test jenkins test this |
Summary
One thing I forgot to correct in my previous PR. The columns are being recreated on every change. That doesn't make the cells to update, but causes the update of rows. The correction makes a significant change for 500 rows table. (from 200ms to 20ms)
Checklist