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

[Meta] Reducing Kibana bundle sizes #88678

Open
24 of 37 tasks
Tracked by #166211
Bamieh opened this issue Jan 19, 2021 · 14 comments
Open
24 of 37 tasks
Tracked by #166211

[Meta] Reducing Kibana bundle sizes #88678

Bamieh opened this issue Jan 19, 2021 · 14 comments
Labels
discuss enhancement New value added to drive a business result performance Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Operations Team label for Operations Team

Comments

@Bamieh
Copy link
Member

Bamieh commented Jan 19, 2021

I was checking opportunities for us to improve page load perofmance for kibana. This is a meta issue with some of my findings. We can create PRs or separate issues for tackling each one on the list individually. I only looked at package.json dependencies; maybe we can get rid of some devDependencies as well to reduce yarn install time in the future.

Bundle specific changes

Copied from #95853

One of our goals is to keep Kibana fast. A large part of this is to reduce the amount of Javascript that is downloaded and parsed on each page load. We have for some time provided bundle size metrics on pull requests. From the docs:

The size of the entry file produced for each bundle/plugin. This file is always loaded on every page load, so it should be as small as possible. To reduce this metric you can put any code that isn’t necessary on every page load behind an async import().

Code that is shared statically with other plugins will contribute to the page load bundle size of that plugin. This includes exports from the public/index.ts file and any file referenced by the extraPublicDirs manifest property.

Cross bundle changes

  • We have multiple encryption libraries (request-crypto, node-crypto, jsonwebtoken and node-forge) A lot of functionality is shared between these libraries, maybe we can get rid of node-forge in favor of node-crypto)

  • We have multiple http fetch libraries: nock, whatwg-fetch, node-fetch, request, load-json-file. Maybe it is worth exploring getting rid of most of those.

  • We have multiple glob libraries: glob, glob-all, globby, minimatch. They all have very similar feature set. Maybe we can explore the possiblity of only ussing 1 package.

  • We have multiple unique id generation packages: seedrandom, uuid. EUI also provides a helper as well to generate uuids. Maybe we can explore using 1 of them only.

  • We have many JSON helper tools: rison-node, JSONStream, deep-freeze-strict, fast-deep-equal, hjson, idx, object-hash, object-path-immutable, set-value. Some of those are only used in 1 place, maybe its worth exploring removing those big libraries.

  • We have two unzip libraries: yauzl, tar. Can we remove one of them?

  • We have at least five redux-like state management packages. [Discussion] State management tools in Kibana #101253

  • remove deprecated intl-relativeformat and update intl-messageformat to the version relying on the global Intl object. [i18n] React-Intl v3 soon out of beta #38642

  • font-awesome is no longer used in EUI. Do we have a plan to get rid of it completely?

  • We are using the complete lodash + few fp.lodash packages. Maybe we can encourage using the fp.lodash packages to only use what we need?

  • We have node APIs usages in client code that are polyfilled and bloat bundles "Buffer" polyfill bloats plugin bundles #107280

  • Use packages' target_web builds to ensure browser compatibility (Use target_web to ensure browser compatibility #130874)

Complete

Moving packages from dependencies to devDependencies is just for keeping things tidy. Operations filter down unused dependencies before bundling. Feel free to edit this issue ❤️

@Bamieh Bamieh added discussion enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Jan 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@pgayvallet pgayvallet added the Team:Operations Team label for Operations Team label Jan 20, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@mshustov
Copy link
Contributor

mshustov commented Feb 5, 2021

There are lots of packages duplicated in yarn.lock with different versions(see d3, vega, and others).
Is it possible to automate the check that dependency update reduces the number of different versions?

@spalger
Copy link
Contributor

spalger commented Feb 5, 2021

We have a step in kbn bootstrap that inspects the yarn.lock, package.json, etc, and could definitely implement some dedupe validation if we could define the exact criteria we want to implement. I'm in favor of keeping a list of dependencies which we explicitly want to limit like we've done for lodash

@Bamieh
Copy link
Member Author

Bamieh commented Feb 15, 2021

I've created a PR to remove xregexp dependency from the codebase (#91369)

@mshustov
Copy link
Contributor

@Bamieh are there any plans to remove deprecated intl-relativeformat and update intl-messageformat to the version relying on the global Intl object?

@Bamieh
Copy link
Member Author

Bamieh commented Feb 16, 2021

@restrry yes! I have an issue for upgrading those in the backlog. I'll add it to the list above too 👍

@mshustov
Copy link
Contributor

mshustov commented Mar 3, 2021

@Bamieh Some code still uses Bluebird we can migrate to native Promises instead

@Bamieh
Copy link
Member Author

Bamieh commented Mar 4, 2021

@restrry added to the list. Native promises caught up with both performance and features to what bluebird used to offer.

@Bamieh
Copy link
Member Author

Bamieh commented Mar 23, 2021

I've created a PR to remove bluebird dependency from the codebase (#95191)

@tylersmalley tylersmalley added 1 and removed 1 labels Oct 11, 2021
@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 Nov 5, 2021
@watson
Copy link
Contributor

watson commented Nov 9, 2021

I took a stab at removing bluebird in main: #118097

@watson
Copy link
Contributor

watson commented Nov 11, 2021

Bluebird removed ✅

@Bamieh
Copy link
Member Author

Bamieh commented Nov 30, 2021

@watson you're awesome :) thanks

@tylersmalley tylersmalley removed loe:small Small Level of Effort impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. EnableJiraSync labels Mar 16, 2022
@vadimkibana
Copy link
Contributor

AppServices is the main user of rison-node.

@lizozom lizozom changed the title [Meta issue] Reducing kibana bundle size [Meta issue] Reducing kibana bundle sizes Apr 18, 2022
@lizozom lizozom changed the title [Meta issue] Reducing kibana bundle sizes [Meta] Reducing kibana bundle sizes Apr 18, 2022
@lizozom lizozom changed the title [Meta] Reducing kibana bundle sizes [Meta] Reducing Kibana bundle sizes Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss enhancement New value added to drive a business result performance Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Operations Team label for Operations Team
Projects
None yet
Development

No branches or pull requests

10 participants