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

[data] Reduce data bundle size #84788

Closed
Tracked by #88678
lukeelmers opened this issue Dec 2, 2020 · 6 comments
Closed
Tracked by #88678

[data] Reduce data bundle size #84788

lukeelmers opened this issue Dec 2, 2020 · 6 comments
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Search Querying infrastructure in Kibana impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort performance technical debt Improvement of the software architecture and operational architecture

Comments

@lukeelmers
Copy link
Member

Currently the initial page load bundle size for the data plugin sits around 1MB. We made an initial effort to lazy-load the UI components which saved about 200k, but that was really the only low-hanging fruit in the plugin.

Since data contains so much code and is relied on by nearly every plugin, there's only so much we can practically do to reduce the bundle size further, but should consider if there's anything we can do to improve the situation.

Screen Shot 2020-10-01 at 2 59 12 PM

One particularly significant chunk of the bundle size comes from data.search.aggs, which registers a bunch of default agg types during setup, representing dozens of modules (about 97 modules that comprise ~20-25% of the bundle size). es_query is another chunk that feels larger than it needs to be.

There are a few options for improving the situation, but one thing in particular I thought might work for aggs is making registries async where possible.

In the case of aggs, we could cut out the majority of the bundle size if retrieving aggs from the registry was an asynchronous operation. Currently a function is added to the registry in setup, which when called during start will return the underlying agg type. If retrieving the aggs were async, then each of the registered functions could lazy import the modules only the first time they are needed.

A similar approach could be applied to other registries which have a number of default items added during setup (eg field formats?): If you register an async provider function for a registry item, and make the registry itself async, then you can lazy load items inside the provider only when they are needed.

@lukeelmers lukeelmers added performance technical debt Improvement of the software architecture and operational architecture Team:AppServices labels Dec 2, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@streamich streamich added Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Search Querying infrastructure in Kibana labels May 4, 2021
@streamich
Copy link
Contributor

Similar issue: #95859

@streamich
Copy link
Contributor

Some ideas of how to shrink the data plugin's initial .js bundle from looking at the composition screenshot.

  1. Make field formats and aggregations load async. But make the formatting still synchronous or possibly reactive. That would remove those parts:

image

  1. Expression functions are async, we can load esaags expression function using dynamic import, it would remove:

image

  1. Not sure why we have those huge CSS files, but we can structure CSS such that it only loads with React components that all can be loaded lazily, unless those are some global CSS theme (in which case they probably should not be part of the data plugin):

image

  1. Maybe Index Patterns should be its own plugin?

image

  1. For KQL we can probably do the same as for field formats/aggregations—load them lazily but still expose synchronous or reactive API:

image

@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 2, 2021
@lizozom
Copy link
Contributor

lizozom commented Jul 1, 2021

#103530 should split out the whole es_query folder into a package.

@vadimkibana
Copy link
Contributor

Thank you for contributing to this issue, however, we are closing this issue due to inactivity as part of a backlog grooming effort. If you believe this feature/bug should still be considered, please reopen with a comment.

@vadimkibana vadimkibana closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2022
@lukeelmers
Copy link
Member Author

By closing this issue, does this mean we no longer intend to take steps to reduce the data plugin's initial bundle size? Or are we saying that we have already exhausted the low-hanging fruit, and any further improvements would require a much larger investment?

"closing due to inactivity" doesn't help me understand if the <100k bundle size goal is still something we intend to achieve. If there are places the bundle can be reduced without too much effort, I'd vote to keep this open since bundle size continues to be a big challenge across Kibana (regardless of how much activity this issue has gotten). But if further improvements are unrealistic at this point, then I understand closing the issue.

cc @tylersmalley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Search Querying infrastructure in Kibana impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort performance technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

No branches or pull requests

5 participants