Skip to content

Perf: EuiDataGrid don't recreate columns on every change#2676

Merged
mbondyra merged 4 commits intoelastic:masterfrom
mbondyra:perf-data-grid-take-2
Dec 17, 2019
Merged

Perf: EuiDataGrid don't recreate columns on every change#2676
mbondyra merged 4 commits intoelastic:masterfrom
mbondyra:perf-data-grid-take-2

Conversation

@mbondyra
Copy link
Copy Markdown
Contributor

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

  • Check against all themes for compatability in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

const raw_data = [];

for (let i = 1; i < 100; i++) {
for (let i = 1; i < 500; i++) {
Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

@mbondyra mbondyra Dec 17, 2019

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not filter first?

Copy link
Copy Markdown
Contributor Author

@mbondyra mbondyra Dec 17, 2019

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 🤔

Copy link
Copy Markdown
Contributor

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 🤷‍♀

Copy link
Copy Markdown
Contributor

@chandlerprall chandlerprall left a 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!

@chandlerprall
Copy link
Copy Markdown
Contributor

CI failure is a flaky test

jenkins test this

@mbondyra mbondyra merged commit 1db929c into elastic:master Dec 17, 2019
@mbondyra mbondyra deleted the perf-data-grid-take-2 branch December 17, 2019 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants