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

[WIP] - Improve performance #212173

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michaelolo24
Copy link
Contributor

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@michaelolo24 michaelolo24 added performance release_note:skip Skip the PR/issue when compiling release notes v9.0.0 Team:Threat Hunting:Investigations Security Solution Investigations Team v8.18.0 v9.1.0 v8.19.0 v8.17.3 labels Feb 22, 2025
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

securityLayout: { getPluginWrapper },
},
} = useKibana();
export const PluginTemplateWrapper: FC<KibanaPageTemplateProps> = React.memo(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prevent multiple re-renders of the UI

@@ -67,10 +66,10 @@ export const useSourcererDataView = (
if (selectedDataView == null || missingPatterns.length > 0) {
// old way of fetching indices, legacy timeline
setLegacyPatterns(selectedPatterns);
} else {
} else if (legacyPatterns.length > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A new [] was being created on every run of this hook, thereby updating state, thereby re-rendering every component where this hook is being called

@@ -37,7 +40,9 @@ export const UnifiedTimelineBody = (props: UnifiedTimelineBodyProps) => {
leadingControlColumns,
onUpdatePageIndex,
} = props;

const dataView = useGetScopedSourcererDataView({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed withDataView in favor of this call as it only happens in one place in the tree since the only other location it was used was the child component UnifiedTimeline here

<HideShowContainer
$isVisible={TimelineTabs.query === activeTimelineTab}
data-test-subj={`timeline-tab-content-${TimelineTabs.query}`}
<OnDemandRenderer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only load the components when you click on the tab, but it remains rendered after first load

* every time timeline is closed and re-opened after the first interaction.
*/

const getTimelineShowStatus = useMemo(() => getTimelineShowStatusByIdSelector(), []);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary anymore as the entire tabs are now being rendered on demand

const categoryBrowserFields = Object.values(browserFields[categoryId]?.fields ?? {});
if (categoryBrowserFields.length > 0) {
fieldItemsAcc.push(
Copy link
Contributor Author

@michaelolo24 michaelolo24 Feb 22, 2025

Choose a reason for hiding this comment

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

At scale this was crashing the browser (tested with 500k fields):
Screenshot 2025-02-22 at 12 47 53 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-02-22 at 12 47 59 AM

@michaelolo24 michaelolo24 force-pushed the improve-security-solution-performance branch from 6f23250 to f03d9db Compare February 22, 2025 11:46
@michaelolo24
Copy link
Contributor Author

/ci

@michaelolo24 michaelolo24 force-pushed the improve-security-solution-performance branch from 62d9a8b to cd514e9 Compare February 22, 2025 13:05
@michaelolo24
Copy link
Contributor Author

/ci

@michaelolo24
Copy link
Contributor Author

/ci

@elasticmachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.17.3 v8.18.0 v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants