[unified search] optimize async chunk loading#214483
Conversation
|
/ci |
|
/ci |
|
/ci |
|
/ci |
| order: 1, | ||
| mount: async (params) => { | ||
| const { renderApp, services, store } = await mountDependencies(); | ||
| const { ManagementSettings } = await this.lazyAssistantSettingsManagement(); |
There was a problem hiding this comment.
Not part of fix but I saw this while in the file. This creates a waterfall of chunk loading. I moved ManagementSettings chunk loading into mountDependencies to avoid this waterfall.
|
/ci |
|
@elasticmachine merge upstream |
|
/ci |
1 similar comment
|
/ci |
| await this.registerActions(store, params.history, core, services); | ||
| if (!this._actionsRegistered) { | ||
| this._actionsRegistered = true; | ||
| registerActions(store, params.history, core, services); |
There was a problem hiding this comment.
Isn't this function async now? Don't you think we should await?
There was a problem hiding this comment.
The results of registerActions are not used so I did not think an await was needed. I will defer to your team if await is required. Just let me know.
There was a problem hiding this comment.
This function is async now because you changed that here
Does this really need to be async?
There was a problem hiding this comment.
Does this really need to be async?
Yes, because createFilterAction from import { createFilterAction } from '@kbn/unified-search-plugin/public'; is now async to avoid including createFilterAction in unifiedSearch bundle
There was a problem hiding this comment.
Okay, but this is not awaiting anything unless we also await the registerDiscoverHistogramActions call inside registerUIActions, right?
There was a problem hiding this comment.
registerUIActions needs to be async so that registerDiscoverHistogramActions can be async. Let me know if you have any further questions
There was a problem hiding this comment.
@nreese Sure, let me rephrase the question.
Why is the registerDiscoverHistogramActions() call not awaited here?
There was a problem hiding this comment.
Thanks for clarifying, added await 98fc7a7
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
ThomThomson
left a comment
There was a problem hiding this comment.
Tested this locally in chrome and looked through the code. Nice clean change list, great bundle reductions, and a good start to our ownership of Unified Search.
Changes LGTM! Left a few small comments.
| unifiedDocViewer: 25099 | ||
| unifiedHistogram: 19928 | ||
| unifiedSearch: 71059 | ||
| unifiedSearch: 23000 |
There was a problem hiding this comment.
Great to see this coming down!
| @@ -42,9 +42,7 @@ interface State { | |||
| fieldLabel?: string; | |||
| } | |||
|
|
|||
| // Needed for React.lazy | |||
| // eslint-disable-next-line import/no-default-export | |||
| export default class ApplyFiltersPopoverContent extends Component<Props, State> { | |||
There was a problem hiding this comment.
Good to see this loaded async with the action definition rather than via React lazy.
| * the withSuspense` HOC to load this component. | ||
| */ | ||
| export const DataViewsListLazy = React.lazy(() => import('./dataview_list')); | ||
| export const DataViewsListLazy = React.lazy(async () => { |
There was a problem hiding this comment.
Eventually it would be good to have these exported with their own load states rather than forcing the consumer to use suspense and provide a fallback.
|
|
||
| // Needed for React.lazy | ||
| // eslint-disable-next-line import/no-default-export | ||
| export default FilterBadgeGroup; |
There was a problem hiding this comment.
Great to see the return { default: Component } syntax used for the lazy loading rather than disabling our no-default-export rule.
| export { QuerySuggestionTypes } from './autocomplete/providers/query_suggestion_provider'; | ||
|
|
||
| import { UnifiedSearchPublicPlugin } from './plugin'; | ||
| export async function createFilterAction( |
There was a problem hiding this comment.
I see this is used specifically in Discover. Seems like a strange use case to import an action definition from another plugin and register it again. It's probably out of scope for this PR to separate it out or fix this up but it's definitely a bit of a code smell.
For instance, why can't the trigger just get the actions from a different trigger or get the apply filter action from the registry?
|
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsasync chunk count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
|
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/14096285966 |
PR reduces unifiedSearch chunks into ui chunk, action chunk, and a autocomplete chunk. ### Before <img width="350" alt="Screenshot 2025-03-14 at 8 47 10 AM" src="https://github.com/user-attachments/assets/f54fe21e-7548-48a1-8874-e36377826701" /> ### After The second chunk request is because search bar loads KQL suggestions. This will be addressed in a follow up PR and the search bar will lazy load suggestions only when interacted with. <img width="350" alt="Screenshot 2025-03-14 at 12 56 28 PM" src="https://github.com/user-attachments/assets/8f23ee56-a57a-489b-aeab-caa30f739d03" /> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 3bc1465)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.x`: - [[unified search] optimize async chunk loading (#214483)](#214483) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Nathan Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2025-03-27T00:39:58Z","message":"[unified search] optimize async chunk loading (#214483)\n\nPR reduces unifiedSearch chunks into ui chunk, action chunk, and a\nautocomplete chunk.\n\n### Before\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 8 47 10 AM\"\nsrc=\"https://github.com/user-attachments/assets/f54fe21e-7548-48a1-8874-e36377826701\"\n/>\n\n### After\nThe second chunk request is because search bar loads KQL suggestions.\nThis will be addressed in a follow up PR and the search bar will lazy\nload suggestions only when interacted with.\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 12 56 28 PM\"\nsrc=\"https://github.com/user-attachments/assets/8f23ee56-a57a-489b-aeab-caa30f739d03\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"3bc1465365872d093a9e8ff5666ab0b01738c792","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","backport:version","v9.1.0","v8.19.0"],"title":"[unified search] optimize async chunk loading","number":214483,"url":"https://github.com/elastic/kibana/pull/214483","mergeCommit":{"message":"[unified search] optimize async chunk loading (#214483)\n\nPR reduces unifiedSearch chunks into ui chunk, action chunk, and a\nautocomplete chunk.\n\n### Before\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 8 47 10 AM\"\nsrc=\"https://github.com/user-attachments/assets/f54fe21e-7548-48a1-8874-e36377826701\"\n/>\n\n### After\nThe second chunk request is because search bar loads KQL suggestions.\nThis will be addressed in a follow up PR and the search bar will lazy\nload suggestions only when interacted with.\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 12 56 28 PM\"\nsrc=\"https://github.com/user-attachments/assets/8f23ee56-a57a-489b-aeab-caa30f739d03\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"3bc1465365872d093a9e8ff5666ab0b01738c792"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214483","number":214483,"mergeCommit":{"message":"[unified search] optimize async chunk loading (#214483)\n\nPR reduces unifiedSearch chunks into ui chunk, action chunk, and a\nautocomplete chunk.\n\n### Before\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 8 47 10 AM\"\nsrc=\"https://github.com/user-attachments/assets/f54fe21e-7548-48a1-8874-e36377826701\"\n/>\n\n### After\nThe second chunk request is because search bar loads KQL suggestions.\nThis will be addressed in a follow up PR and the search bar will lazy\nload suggestions only when interacted with.\n<img width=\"350\" alt=\"Screenshot 2025-03-14 at 12 56 28 PM\"\nsrc=\"https://github.com/user-attachments/assets/8f23ee56-a57a-489b-aeab-caa30f739d03\"\n/>\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"3bc1465365872d093a9e8ff5666ab0b01738c792"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nathan Reese <reese.nathan@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
PR reduces unifiedSearch chunks into ui chunk, action chunk, and a autocomplete chunk. ### Before <img width="350" alt="Screenshot 2025-03-14 at 8 47 10 AM" src="https://github.com/user-attachments/assets/f54fe21e-7548-48a1-8874-e36377826701" /> ### After The second chunk request is because search bar loads KQL suggestions. This will be addressed in a follow up PR and the search bar will lazy load suggestions only when interacted with. <img width="350" alt="Screenshot 2025-03-14 at 12 56 28 PM" src="https://github.com/user-attachments/assets/8f23ee56-a57a-489b-aeab-caa30f739d03" /> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
PR reduces unifiedSearch chunks into ui chunk, action chunk, and a autocomplete chunk.
Before
After
The second chunk request is because search bar loads KQL suggestions. This will be addressed in a follow up PR and the search bar will lazy load suggestions only when interacted with.
