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

[Security Solution] useListsConfig performs many repeated /api/lists/index calls #169268

Closed
umbopepato opened this issue Oct 18, 2023 · 9 comments · Fixed by #171412
Closed

[Security Solution] useListsConfig performs many repeated /api/lists/index calls #169268

umbopepato opened this issue Oct 18, 2023 · 9 comments · Fixed by #171412
Assignees
Labels
bug Fixes for quality problems that affect the customer experience enhancement New value added to drive a business result OLM Sprint Team:Defend Workflows “EDR Workflows” sub-team of Security Solution Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc.

Comments

@umbopepato
Copy link
Member

umbopepato commented Oct 18, 2023

The various usages of the useListsConfig hook across DetectionEnginePage cause a lot of repeated GET /arp/api/lists/index http requests (by means of useListsIndex). This causes a lot of unnecessary re-renders in the alerts table, triggered by each row action cell:

Screenshot 2023-10-18 at 17 24 18

As part of our ongoing work to improve the alerts table's performance we've tried to share the lists configuration response through a context, reducing the number of renders from ~500 to ~30.

@umbopepato umbopepato added enhancement New value added to drive a business result Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. labels Oct 18, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@michaelolo24 michaelolo24 added bug Fixes for quality problems that affect the customer experience Team:Defend Workflows “EDR Workflows” sub-team of Security Solution labels Nov 1, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@michaelolo24
Copy link
Contributor

Hey @kevinlog and @ashokaditya - I'm not sure if the defend workflows team is the correct team for this, but based on @kqualters-elastic 's investigation. It may be worth caching the lists call or lifting it out of the use_add_exception_actions.tsx hook so it's not called for every row in the table, thanks!

@yctercero
Copy link
Contributor

Apologies if I'm missing context here, but wondering why the logic inside the take actions components gets called on render. Shouldn't that logic only be invoked when a user clicks on the ... for actions?

@ashokaditya
Copy link
Member

ashokaditya commented Nov 2, 2023

@yctercero Keen observation with the logic. I notice that currently the menu items that should be shown within the ... action menu popup is actually being computed within the same component that's responsible for rendering the ... component. So essentially for each of the row items the (yet to be rendered) menu items are computed even before the menu is open. Consequently the logic to enable/disable the Add endpoint exceptions is being calculated in the same component (the logic uses useListConfig to determine if the user has access to lists index) which is why there's calls to /api/api/lists/index on each table item.

I'm going to have a closer look at this and decouple some logic as you suggest and make a fix.

@kqualters-elastic
Copy link
Contributor

Even if it worked like that, as a user opens the menu for each component, we are making the same exact request, that's not using any data from the document associated with the row in the request itself, as each menu is opened. The problem of repeated, redundant requests still exists. Also think that this was done to play nicely with eui, as this button ultimately is passed along to EuiDataGrid via the leadingControlColumns prop, and updating just the single row control for a row does not seem possible with the current component api. Up until a few weeks ago, everything has worked just fine, something was changed in the overly complicated nested hooks based architecture that drives the menu.

@ashokaditya
Copy link
Member

Thanks for looking into it @kqualters-elastic. The changes that caused this went in last month with this PR /pull/165613.

umbopepato added a commit that referenced this issue Nov 14, 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](#168470 (comment))
to ~180 when expanding the table from 10 to 100 visible rows:


![image](https://github.com/elastic/kibana/assets/18363145/22cb45e4-482d-475d-82b1-3d0a4515bfac)

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


![image](https://github.com/elastic/kibana/assets/18363145/2652071a-2be0-45c8-80fd-cce4f8ccb9b5)


### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Xavier Mouligneau <[email protected]>
ashokaditya added a commit to ashokaditya/kibana that referenced this issue Nov 16, 2023
@ashokaditya
Copy link
Member

PR /pull/171412

kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Nov 22, 2023
…k to check access to`.lists-*` (elastic#171412)

## Summary

Instead of using `useListsConfig` this PR uses `useListPrivileges` to
verify access to `.lists-*` index pattern.

follow up of elastic/pull/165613
related elastic/pull/170671 (closed in favour of this)
fixes elastic/issues/169268

### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 8c3322e)
rshen91 pushed a commit to rshen91/kibana that referenced this issue Nov 22, 2023
…k to check access to`.lists-*` (elastic#171412)

## Summary

Instead of using `useListsConfig` this PR uses `useListPrivileges` to
verify access to `.lists-*` index pattern.

follow up of elastic/pull/165613
related elastic/pull/170671 (closed in favour of this)
fixes elastic/issues/169268

### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <[email protected]>
janmonschke pushed a commit to janmonschke/kibana that referenced this issue Nov 23, 2023
…to check access to`.lists-*` for endpoint exceptions access (elastic#171412) (elastic#171794)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[Serverless][Security Solution][Endpoint] Remove use of hooks to
check access to`.lists-*` for endpoint exceptions access
(elastic#171412)](elastic#171412)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Ash","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-11-22T19:10:50Z","message":"[Serverless][Security
Solution][Endpoint] Remove use of hooks to check access to`.lists-*` for
endpoint exceptions access (elastic#171412)\n\n## Summary\r\n\r\nInstead of
using `useListsConfig` this PR uses `useListPrivileges` to\r\nverify
access to `.lists-*` index pattern.\r\n\r\nfollow up of
elastic/pull/165613\r\nrelated elastic/pull/170671 (closed
in favour of this)\r\nfixes elastic/issues/169268\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"8c3322ed44ccfbc4e91e0e9ef31f77b79c549cb8","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","OLM
Sprint","v8.11.0","v8.12.0","v8.11.1"],"number":171412,"url":"https://github.com/elastic/kibana/pull/171412","mergeCommit":{"message":"[Serverless][Security
Solution][Endpoint] Remove use of hooks to check access to`.lists-*` for
endpoint exceptions access (elastic#171412)\n\n## Summary\r\n\r\nInstead of
using `useListsConfig` this PR uses `useListPrivileges` to\r\nverify
access to `.lists-*` index pattern.\r\n\r\nfollow up of
elastic/pull/165613\r\nrelated elastic/pull/170671 (closed
in favour of this)\r\nfixes elastic/issues/169268\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"8c3322ed44ccfbc4e91e0e9ef31f77b79c549cb8"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/171412","number":171412,"mergeCommit":{"message":"[Serverless][Security
Solution][Endpoint] Remove use of hooks to check access to`.lists-*` for
endpoint exceptions access (elastic#171412)\n\n## Summary\r\n\r\nInstead of
using `useListsConfig` this PR uses `useListPrivileges` to\r\nverify
access to `.lists-*` index pattern.\r\n\r\nfollow up of
elastic/pull/165613\r\nrelated elastic/pull/170671 (closed
in favour of this)\r\nfixes elastic/issues/169268\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"8c3322ed44ccfbc4e91e0e9ef31f77b79c549cb8"}}]}]
BACKPORT-->

Co-authored-by: Ash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience enhancement New value added to drive a business result OLM Sprint Team:Defend Workflows “EDR Workflows” sub-team of Security Solution Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc.
Projects
None yet
7 participants