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

Lazy load Security plugin management apps. #64511

Merged
merged 4 commits into from
Apr 29, 2020

Conversation

azasypkin
Copy link
Member

@azasypkin azasypkin commented Apr 27, 2020

Summary

Measurements are based on this guide.

Before

- 2.7M - security.plugin.js 
- 149K - 1.plugin.js   # I don't know where the chunk `0` is .....
- 175K - 2.plugin.js        
- 135K - 3.plugin.js        
-  32K - 4.plugin.js        
-  13K - 5.plugin.js        
- 3.2K - 6.plugin.js        
- 6.1K - 7.plugin.js        
-  15K - 8.plugin.js        

After

- 269K - security.plugin.js
-  26K - 0.plugin.js
- 150K - 1.plugin.js
-  24K - 2.plugin.js
- 1.9M - 4.plugin.js
- 178K - 5.plugin.js
- 179K - 6.plugin.js
- 100K - 7.plugin.js
-  44K - 8.plugin.js
-  61K - 9.plugin.js
-  35K - 10.plugin.js
- 135K - 11.plugin.js
-  32K - 12.plugin.js
-  35K - 13.plugin.js
-  39K - 14.plugin.js
-  29K - 15.plugin.js
-  23K - 16.plugin.js
-  32K - 17.plugin.js
-  26K - 18.plugin.js
-  58K - 19.plugin.js
-  15K - 20.plugin.js
- 3.5K - 21.plugin.js
- 5.5K - 22.plugin.js
- 2.3K - 23.plugin.js
- 2.8K - 24.plugin.js

Related to: #64192

cc @restrry

@azasypkin azasypkin added performance Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! release_note:skip Skip the PR/issue when compiling release notes v7.8.0 labels Apr 27, 2020
@azasypkin azasypkin requested review from a team as code owners April 27, 2020 11:54
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@@ -7,7 +7,6 @@
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor, ApplicationSetup, AppMountParameters } from 'src/core/public';
import { AuthenticationServiceSetup } from '../authentication';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: decided to lazy load these API clients as well - not a big win, but doesn't cost too much either.

@azasypkin
Copy link
Member Author

@legrego @jportner this one is ready for review whenever any of you have time. If this approach looks good to you, I can prepare a similar one for Spaces management app.

@legrego
Copy link
Member

legrego commented Apr 27, 2020

Thanks for taking this on @azasypkin!

For reference, chunk 3 is the role management app:

./public/management/roles/roles_management_app.tsx

Based on a very quick analysis, my theory is that the data plugin is at least somewhat responsible. I didn't see this referenced in the handful of other chunks that I looked at, and we are including quite a bit from that plugin by the looks of things:

image

IIRC, we only use the data plugin in order to retrieve a list of available index patterns, which drives the index privileges dropdown.

@legrego legrego self-requested a review April 27, 2020 19:12
@azasypkin
Copy link
Member Author

azasypkin commented Apr 28, 2020

Based on a very quick analysis, my theory is that the data plugin is at least somewhat responsible. I didn't see this referenced in the handful of other chunks that I looked at, and we are including quite a bit from that plugin by the looks of things

Good find! Luckily it's not included into our main bundle that is loaded every time.

@legrego
Copy link
Member

legrego commented Apr 28, 2020

I'll finish reviewing this once #63563 is finalized and incorporated into this PR, but so far this is looking good

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment on how the naming of the sass files will need to change. Core idea is great though. Thanks for making this change.

@azasypkin
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@azasypkin
Copy link
Member Author

azasypkin commented Apr 29, 2020

I'll finish reviewing this once #63563 is finalized and incorporated into this PR, but so far this is looking good

Done! The number of chunks tripled, but I'm not worried at this point as the main goal is to decrease size of the main bundle that is loaded every time for every app (decreased to one-tenth of its original size). If it becomes a problem in the future we may manually group chunks together (e.g. load all management apps in one big chunk). I'd not be happy about that level of fine tuning though.

Copy link
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGreatTM, thanks for taking this on!

@azasypkin azasypkin requested a review from snide April 29, 2020 13:58
Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a code review. LGTM.

@azasypkin azasypkin merged commit 5ee6dcd into elastic:master Apr 29, 2020
@azasypkin azasypkin deleted the issue-64192-sec-perf branch April 29, 2020 16:16
azasypkin added a commit to azasypkin/kibana that referenced this pull request Apr 29, 2020
@azasypkin
Copy link
Member Author

7.x/7.8.0: 785c113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported performance release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants