[9.1] [Investigations] - Improve useFieldBrowser performance (#225859)#227004
Merged
michaelolo24 merged 1 commit intoelastic:9.1from Jul 10, 2025
Merged
[9.1] [Investigations] - Improve useFieldBrowser performance (#225859)#227004michaelolo24 merged 1 commit intoelastic:9.1from
michaelolo24 merged 1 commit intoelastic:9.1from
Conversation
## Summary This PR looks to improve the performance of the newly introduced `useBrowserFields` implementation. The currently used `DataViewSpec.fields` isn't performant at scale and is not cached. Existing code is as follows: [DataView.toSpec](https://github.com/elastic/kibana/blob/27183690142a5590b4ad72d060c43cad869f3f3c/src/platform/plugins/shared/data_views/common/data_views/data_view.ts#L147) call as seen [here](https://github.com/elastic/kibana/blob/27183690142a5590b4ad72d060c43cad869f3f3c/src/platform/plugins/shared/data_views/common/data_views/abstract_data_views.ts#L391-L422), [here](https://github.com/elastic/kibana/blob/27183690142a5590b4ad72d060c43cad869f3f3c/src/platform/plugins/shared/data_views/common/fields/field_list.ts#L157-L159), and finally [here](https://github.com/elastic/kibana/blob/27183690142a5590b4ad72d060c43cad869f3f3c/src/platform/plugins/shared/data_views/common/fields/data_view_field.ts#L438-L440). While this may not be a significant issue at a few thousand fields, this does not scale well as the number of fields reaches the tens to hundreds of thousands. [Separate PR](elastic#225726) that moves away from spec usage to pure `DataView` usage The `useFieldsBrowser` hook is improved by relying directly on the DataView rather than the DataViewSpec. And there are improvements to the original sourcerer fieldBrowser calculation. Currently the use of `memoizeOne` doesn't actually work as the fields object passed to it is an object and not an array. A new fieldBrowserManager was introduced that caches based on the scope. Originally investigated caching via a `WeakMap` to avoid the scenario where all 4 (current) scopes cache the exact same DataView, but it looked like references to previously selected dataViews retained a strong reference in memory, which often led to all N number of selected dataViews being retained in the cache. The current approach is safer as the number of cached entries are capped at `DataViewManagerScopeName.length` ** Relevant configurations ** `xpack.securitySolution.enableExperimental: ['newDataViewPickerEnabled']` (cherry picked from commit 9a18757) # Conflicts: # x-pack/solutions/security/plugins/security_solution/public/cases/components/ai_for_soc/table.tsx
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
|
michaelolo24
commented
Jul 10, 2025
| TOOLBAR_VISIBILITY, | ||
| } from '../../../detections/components/alert_summary/table/table'; | ||
| import { ActionsCell } from '../../../detections/components/alert_summary/table/actions_cell'; | ||
| import { getDataViewStateFromIndexFields } from '../../../common/containers/source/use_data_view'; |
Contributor
Author
There was a problem hiding this comment.
this is the only removed import, the other ones were just moved above and useBrowserFields and DataViewManagerScopeName are added
agusruidiazgd
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto9.1:Questions ?
Please refer to the Backport tool documentation