-
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
[Lens] Optimize async chunks #211921
[Lens] Optimize async chunks #211921
Conversation
/ci |
/ci |
/ci |
…into fix/speed-up-lens
/ci |
/ci |
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsasync chunk count
References to deprecated APIs
History
cc @dej611 |
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.
All good here, the room for improvement exist, but this is a great step toward that.
Thanks
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.
I just have a couple of questions about the Data Discovery changes.
...ackages/shared/kbn-unified-field-list/src/components/field_item_button/field_item_button.tsx
Show resolved
Hide resolved
src/platform/packages/shared/kbn-unified-field-list/src/components/field_item_button/index.tsx
Outdated
Show resolved
Hide resolved
…into fix/speed-up-lens
…urce-definitions/scripts/fix-location-collection.ts'
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.
I don't think you need my review anymore with the latest changes, but LGTM nonetheless!
src/platform/packages/shared/kbn-unified-field-list/src/components/field_item_button/index.tsx
Outdated
Show resolved
Hide resolved
…urce-definitions/scripts/fix-location-collection.ts'
Sorry folks for the new ping. After some changes I've settled with this setup which makes the async bundle size go a little bit higher, but with fewer async chunks to load. |
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.
Latest Data Discovery changes to export GenericFieldItemButtonType
make sense to me now that I understand the challenges with generic components and lazy loading 👍
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
References to deprecated APIs
History
cc @dej611 |
This PR, and another Lens-focussed one (#215792), have shown a big improvement in how long it takes to load a dashboard. Both of them together have caused the median |
## Summary While documenting some Lens architecture I've noticed how chunks are organized in Lens, so I've taken a quick spin to reduce the amount of requests to load a dashboard panel and more in general the number of async chunks produced by webpack. This PR aims to do 2 things: * optimize the number of chunks generated by webpack * optimize the number of requests done to load a Lens embedable panel * optimize any `await` flow to do **other things ™️ ** while in idle to load ### Final results #### Reduce the number of chunks The final number of chunks got reduced from 24 to 15. The bundle size has remained almost the same. | Before | After | | ------------- | ------------- | | <img width="1443" alt="Screenshot 2025-03-10 at 12 53 21" src="https://github.com/user-attachments/assets/65030955-7b7c-493c-9559-fbb9ef9089d4" /> | <img width="1101" alt="Screenshot 2025-03-10 at 12 51 53" src="https://github.com/user-attachments/assets/99b9b78d-931a-40ed-bda6-820584c1337e" /> | There's still some improvement margin here, but the changes mainly includes he followings: * the embeddable is now bundled together with the `async_services` bundle * as both are required to render the panel in a dashboard, this change should speed up a bit the dashboard use case vs the Lens editor one * Expression implementations has been deferred into their separate bundles * this should reduce a bit the initial `plugin.js` bundle by few kb * most of the times the bundled expressions are used together, so it makes sense to bundle those 3/4 together rather than have 4 tiny bundles to async load and prevent waterfall `async import` calls which led to poor performance * Defer a component in the `@kbn/unified-field-list` component * this was making load some edit component within the `async_services` bundle even in dashboard. * because this is a component only required in Lens editor, this has been deferred * Async register actions as recommended by @nreese #### Reduce the number of requests The final number of chunks requested to load a lens panel on a dashboard went from 12 to 4. The overall bundle size has remained almost the same, but the distributions of weights have slightly changed. Surprisingly there's 1 MB which is gone somewhere, but that doesn't seem to have an actual impact on the overall loading experience yet. | Before | After | | ------------- | ------------- | | <img width="1445" alt="Screenshot 2025-03-10 at 12 58 08" src="https://github.com/user-attachments/assets/faab091b-305d-43ad-8be2-2f3bb83913a3" /> | <img width="1110" alt="Screenshot 2025-03-10 at 12 58 32" src="https://github.com/user-attachments/assets/f88ac9f5-80a6-42d3-8e3b-3013df05cb8b" /> | #### Optimize any `await` call Well, this is hard to test. So I have no direct proof at the moment. 🤷 cc @thomasneirynck --------- Co-authored-by: kibanamachine <[email protected]>
Summary
While documenting some Lens architecture I've noticed how chunks are organized in Lens, so I've taken a quick spin to reduce the amount of requests to load a dashboard panel and more in general the number of async chunks produced by webpack.
This PR aims to do 2 things:
await
flow to do **other things ™️ ** while in idle to loadFinal results
Reduce the number of chunks
The final number of chunks got reduced from 24 to 15. The bundle size has remained almost the same.
There's still some improvement margin here, but the changes mainly includes he followings:
async_services
bundleplugin.js
bundle by few kbasync import
calls which led to poor performance@kbn/unified-field-list
componentasync_services
bundle even in dashboard.Reduce the number of requests
The final number of chunks requested to load a lens panel on a dashboard went from 12 to 4.
The overall bundle size has remained almost the same, but the distributions of weights have slightly changed.
Surprisingly there's 1 MB which is gone somewhere, but that doesn't seem to have an actual impact on the overall loading experience yet.
Optimize any
await
callWell, this is hard to test. So I have no direct proof at the moment. 🤷
cc @thomasneirynck