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

[Observability] Optimize initial load bundles #191599

Closed
5 tasks done
tonyghiani opened this issue Aug 28, 2024 · 3 comments
Closed
5 tasks done

[Observability] Optimize initial load bundles #191599

tonyghiani opened this issue Aug 28, 2024 · 3 comments
Assignees
Labels
epic Team:obs-ux-logs Observability Logs User Experience Team

Comments

@tonyghiani
Copy link
Contributor

tonyghiani commented Aug 28, 2024

📓 Summary

When loading Kibana on the browser, the plugin architecture loads an initial js bundle file typically named <plugin-name>.plugin.js , which performs all the necessary registrations so that any other plugin can use shared logic with different ownership.

When loading any Kibana page, even an unaccessible page, we transfer a minimum of ~5.5 Mb of compressed resources, including any optimization performed at build time such as tree-shaking, code minification etc, resulting in a minimum of +20 Mb uncompressed resources for the browser to process on the user machine.

The JS bundle files represent a ~90% (5 Mb) of the total transferred resources.

  • The JS *.plugin.js files represent ~30% (1.5 Mb) of JS transferred resources.
  • The JS *.chunk.<integer>.js files represent ~28% (1.4 Mb) of the total transferred resources.
  • The JS kbn-ui-shared-deps-*.js files represent ~38% (1.9 Mb) of the total transferred resources.
  • Other core JS files represent ~4% (200 Kb) of the total transferred resources.

Of all the JS code transferred to the browser on the first load, only ~41% is executed, meaning almost 60% of it needs to be parsed by the browser without even using it.

Ideally, JS *.chunk.<integer>.js files represent chunks of code that should be loaded asynchronously only when necessary to load specific features (visiting an app page, loading a registered alert, etc.).

Their presence on the initial page load means we are sometimes splitting code into multiple chunks and immediately loading them even if not necessary.

Important

Re-organizing the lazy-loading around this file might change slightly the *.plugin.js files, but should give us a huge opportunity to cut ~25% of all the loaded code on the first visit for many Kibana features.

If we also detect an opportunity to lazy load more features, it implies a potential size reduction of the *.plugin.js files too.

Another important data: kbn-ui-shared-deps-*.js files are the biggest code chunks sent to the browser, and only ~50% is used on initial load, reaching ~60-65% after browsing into multiple apps. There might be an opportunity to detect multiple libraries that don’t need to be immediately bundled.

Observability bundling issues

A deeper investigation into the Observability plugins implementation spotted some critical insights:

  • ~24% (1.2 Mb) of the total transferred JS code is from Observability plugins
  • APM loads the biggest async *.chunk.<integer>.js file in Kibana, which represents ~16% of all the transferred resources.

Following here is a list of potential optimizations we can perform in Observability to reduce the impact of our JS bundle.

Tasks

Preview Give feedback
  1. Team:obs-ux-infra_services apm:performance bug performance
    tonyghiani
  2. Team:obs-ux-logs
    tonyghiani
  3. Team:obs-ux-infra_services
    crespocarlos
  4. tonyghiani
  5. Team:obs-ux-logs
@tonyghiani tonyghiani self-assigned this Aug 28, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Aug 28, 2024
@tonyghiani tonyghiani added Team:obs-ux-logs Observability Logs User Experience Team and removed needs-team Issues missing a team label labels Aug 28, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs)

@thomasneirynck
Copy link
Contributor

For visibility, the same problem exists elsewhere also:

@tonyghiani
Copy link
Contributor Author

Closing as sub-tasks are completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Team:obs-ux-logs Observability Logs User Experience Team
Projects
None yet
Development

No branches or pull requests

3 participants