-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Performance][Security Solution][3/4] - Sourcerer performance #212482
Changes from all commits
f2eea0d
21021d1
99c561e
409bdff
7d15592
54ad721
1bcff31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,7 +178,7 @@ export const useInitSourcerer = ( | |
!loadingSignalIndex && | ||
signalIndexName != null && | ||
signalIndexNameSourcerer == null && | ||
(activeTimeline == null || activeTimeline.savedObjectId == null) && | ||
activeTimeline?.savedObjectId == null && | ||
initialTimelineSourcerer.current && | ||
defaultDataView.id.length > 0 | ||
) { | ||
|
@@ -209,7 +209,7 @@ export const useInitSourcerer = ( | |
); | ||
} else if ( | ||
signalIndexNameSourcerer != null && | ||
(activeTimeline == null || activeTimeline.savedObjectId == null) && | ||
activeTimeline?.savedObjectId == null && | ||
initialTimelineSourcerer.current && | ||
defaultDataView.id.length > 0 | ||
) { | ||
|
@@ -240,14 +240,14 @@ export const useInitSourcerer = ( | |
); | ||
} | ||
}, [ | ||
activeTimeline, | ||
activeTimeline?.savedObjectId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we only care about the id value, don't re call due to |
||
defaultDataView, | ||
dispatch, | ||
loadingSignalIndex, | ||
signalIndexName, | ||
signalIndexNameSourcerer, | ||
]); | ||
const { dataViewId } = useSourcererDataView(scopeId); | ||
const { dataViewId, browserFields } = useSourcererDataView(scopeId); | ||
|
||
const updateSourcererDataView = useCallback( | ||
(newSignalsIndex: string) => { | ||
|
@@ -370,4 +370,11 @@ export const useInitSourcerer = ( | |
signalIndexName, | ||
signalIndexNameSourcerer, | ||
]); | ||
|
||
return useMemo( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return browser fields from Other change here: |
||
() => ({ | ||
browserFields, | ||
}), | ||
[browserFields] | ||
); | ||
}; |
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.
sourcerer was unnecessarily re-rendering due to a reference change that took place because of an empty array being replaced with a new empty array. It could also be solved by pulling out a
const emptyArray = []
and re-using that but just went with theif
check instead...