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

[RAM] Add option to disable virtualization in alerts table #169257

Merged
merged 13 commits into from
Nov 14, 2023

Conversation

umbopepato
Copy link
Member

@umbopepato umbopepato commented Oct 18, 2023

Closes #168470

Summary

Adds a dynamicRowHeight option to the alerts table that replaces the virtualized table body with a custom non-virtualized one to improve the performance of variable row heights (even though the rows weren't recycled the auto height was causing a lot of unnecessary re-renderings).

When enabled, this option reduces the amount of re-renders from ~500 to ~180 when expanding the table from 10 to 100 visible rows:

image

When combined with a possible solution to #169268 , the number of renders drastically reduces to around 30:

image

Checklist

Delete any items that are not applicable to this PR.

@umbopepato umbopepato force-pushed the 168470-security-alerts-table-perf branch from fa984ba to 0aaa207 Compare October 18, 2023 15:16
className={`euiDataGridRow ${
rowIndex % 2 !== 0 ? 'euiDataGridRow--striped' : ''
}`}
key={rowIndex}
Copy link
Contributor

@kqualters-elastic kqualters-elastic Oct 18, 2023

Choose a reason for hiding this comment

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

maybe key={${rowIndex},${pagination.pageIndex}} like below, rowIndex will be identical when changing pages

<Row
role="row"
className={`euiDataGridRow ${
rowIndex % 2 !== 0 ? 'euiDataGridRow--striped' : ''
Copy link
Contributor

@cee-chen cee-chen Oct 23, 2023

Choose a reason for hiding this comment

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

[Optional heads up] If/when EUI converts EuiDataGrid from Sass to Emotion/CSS-in-JS*, this euiDataGridRow--striped className will stop working. You may want to consider baking this logic into your styled.div now, if that's an option - the color being used is euiColorLightestShade.

*Note: if another team ends up taking ownership of EuiDataGrid and it moves out of EUI, this migration may not end up happening, so totally up to you all as if you'd rather address this later.

@@ -560,6 +560,10 @@ export type AlertsTableProps = {
* Allows to consumers of the table to decide to highlight a row based on the current alert.
*/
shouldHighlightRow?: (alert: Alert) => boolean;
/**
* Enable when rows may have variable heights (disables virtualization)
Copy link
Contributor

Choose a reason for hiding this comment

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

[attaching to a semi random line for threading]

Are there any plans on limiting the potential number of rows per page for non-virtualized data grids? It's likely that you're going to run into major lag/perf issues rendering 1000 rows at once, for example 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

As of today, we can only show a maximum of 100 alert in the table

Copy link
Contributor

@cee-chen cee-chen Nov 14, 2023

Choose a reason for hiding this comment

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

👍 If you run into performance issues with large grids and 100 rows, it may be worth considering going down to a max of 50, or potentially another perf approach like lazy loading.

@umbopepato umbopepato force-pushed the 168470-security-alerts-table-perf branch from 350bb85 to 0f164d2 Compare October 30, 2023 15:15
@umbopepato umbopepato marked this pull request as ready for review November 9, 2023 19:18
@umbopepato umbopepato requested review from a team as code owners November 9, 2023 19:18
@umbopepato umbopepato added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.12.0 labels Nov 9, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@umbopepato umbopepato requested a review from XavierM November 9, 2023 19:19
stripes?: boolean;
};

const CustomGridBody = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

should make this a React.memo

Copy link
Contributor

Choose a reason for hiding this comment

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

Kevin is correct here!

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

LGTM (code review only)! Awesome work Umberto, I'm so excited that someone's using the new custom body API in production! 🎉

@umbopepato umbopepato enabled auto-merge (squash) November 14, 2023 08:30
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
triggersActionsUi 600 616 +16

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 13.0MB 13.0MB +53.0B
triggersActionsUi 1.4MB 1.4MB +12.9KB
total +13.0KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@umbopepato umbopepato merged commit e86fa36 into elastic:main Nov 14, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Nov 14, 2023
@umbopepato
Copy link
Member Author

LGTM (code review only)! Awesome work Umberto, I'm so excited that someone's using the new custom body API in production! 🎉

Thank you @cee-chen for your help and feedback! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAM] Investigation around the performance of the alert table
7 participants