-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Kibana loading performances optimizations #62263
Comments
To start the discussion, I got a couple questions regarding the NP plugins optimizer: (apologies in advance if any or all of them have already been discussed numerous times)
|
|
This is exclusive to legacy plugins as it is created by webpack analyzing the modules in each bundle and requires that each plugin use a separate bundle. This is not how the new platform builds work, in oder to make them plug-and-play they need to be totally independent so they're made by different webpack instances and therefor can't be chunked in the same way.
Yes, probably, but we created
That is true, and the main reason is because we need to isolate the build steps for the different plugins, which means there can't be a webpack instance that is organizing modules into different chunks by detecting repetitive uses. As mentioned, I'm looking into ways we can elevate enormous dependencies like the legacy
Yes, this works and @restrry is working on making sure that it's used in more places. We could probably use help with finding patterns that we can spread around to different plugin teams. Part of #16085 will be raising awareness of how big certain plugins are and how they're impacting Kibana load times.
If you run
No, but that is my primary goal for 7.8. |
My webpack knowledge starts to be rusty, but can't this be resolved with a
This is excellent news. We really need to identify pattern / best practice and push that to the other teams. The first obvious usage would be to use split points into applications' |
Examples in the migration guide use async imports. What we can improve:
|
updated migration guide with code splitting examples #62593 |
@spalger Is there any reason we can't use Webpack's public path feature instead of the public path replacements we do at bundle serve time? I don't know if that processing is actually a bottleneck, but I wouldn't be surprised if it consumes a non-trivial amount of CPU and delays the serving of the bundle. Would be worth benchmarking with and without that processing to see. |
Yeah, if we use the webpack feature we have to embed the basePath in the bundles and reoptimize when the basePath is changed. This is how we used to do things. I do think we could run the replacement once and store the result to disk when the basePath changes rather than doing the replacement at request time, at least if we have the ability to write to the file system. |
Can we leverage |
Yeah I was hoping we could just pull it from a global variable on window instead. It’s not clear whether or not this is supported from the docs. |
Not sure if it's a real supported API, however I've been using the |
How bad the problem is?We don’t know since we don’t yield any real user metrics. Any development time parameters could be misleading, and we can spend time fixing the wrong problem. Action points:
Fixing root causesNumber of parallel requests to load plugin bundlesProblem
Open questions:
Alternatives to discuss:
Bloated js artifactsProblem
Problem
Problem
Problem
Problem Packages import the whole library, even only some components are needed. There was a suggestion to use https://www.npmjs.com/package/babel-plugin-transform-imports to change import paths allowing only used components to be imported. Open questions:
Risks
|
Something to note; separate CSS and common/vendor files are only from the legacy platform. |
This may be one of the best 80/20 solutions right now. The strategy I've seen used before is to include a timestamp (set to the last modified date of the file) or a version number in the URL search parameters and then set cache-control to This great eliminates the number of requests the browser needs to make since it does not need to re-fetch the etag header from the server. The cache busting mechanism just becomes the query parameter which we can ensure changes anytime the file changes. This does not help the cold start performance, but may have a big impact on every subsequent page load. Could be easily tested without having to write much code. If we went this route, the easiest option would be to only use this strategy for bundles built by the new optimizer since we know those never change in production. |
Plan for 7.8 release:
|
Looked into using different compression, specifically, the brotli algo. One thing about this compression is that it is quite slow on the compression side, so it’s only useful if you have static content that you can compress ahead of time. Due to the “replace public path” processing we do at request time, this is not an option for us. We will need to figure out how to remove this processing by enabling webpack to dynamically look this up at runtime. |
As discussed in our sync today - there is an opportunity to also remove the |
I can take a look at this, though I'm not optimistic it will make a big difference. I'm also experimenting with making the public path dynamic to unblock using brotli. The complicated part is injecting the |
I’m fairly confident that we use bootstrap.js for CSP reasons, but I’m not totally sure.
Could we just set |
Unfortunately, I don't think so. This variable isn't a global variable, it's a webpack "free variable" that must be in the compiled code and is set in each webpack runtime. Another trick thing is that this code variable should be set before any other code executes, and since you cannot execute code before ES imports, we have to add an import to the top of the entry point module that points to module that sets this. My initial idea is to add a Webpack plugin or loader that appends an import to each entry point to import a synthetic module that just contains |
I've put up a PR for setting the public path in the JS runtime: #64226 This unblocks brotli compression which I will work on as a follow up. |
Sorry for jumping in to the issue, Thought I might give a hand/provide some info as I have some prior experience working on this area.
Max agent would definitely work in most of the cases but not on reload as browser still hits the server and validates the cache of the resource. Could we also add cache-control: max-age:<secs>; immutable You can read more about the immutable caching in this article
Happy to help here in any way I can to capture more Metrics. We have a really good setup in running benchmarks with our Real User Monitoring agent and we not only capture the bundle size, but also capture CPU time spent by the bundle, Memory contribution of some of the hot functions on the agent's code. Some details are in this Benchmarks readme. Happy to go over the setup if it's of interest.
We have the APM agents running already on dev. Will it make sense to extend it for our users as well? Love this initiative. Kudos to the team 🎉 |
great stuff here. is this limited to our targets for 7.8? a few somewhat out of the theme options below. more in the possibly worth investigating brain dump category than confirmed. i can put these somewhere else, don't want to clutter. ui
http
npm
assets
|
@vigneshshanmugam
Do you collect metrics for the |
All listed improvements up to 7.9 have been addressed. Closing, for further/additional points, independent issues should be opened. |
Starting with 7.7, there has been a significant increase in the Kibana loading time (#62238 for example)
This issue is here to discuss with @elastic/kibana-platform and @elastic/kibana-operations to list the possible improvements that could be done
We got some work in progress regarding some possible optimizations from the platform team:
Plan for 7.9 release:
Plan for 7.8 release:
@spalger is working on a reporter to collect performance metrics on CI and store them in a dedicated ES cluster. [meta] Metrics for CI reports #16085 @dmlemeshko will add API gathering Performance metrics via WebDriver to add those data to the reporter.etag
to hash-based filenames withmax-age
header to avoid a round trip per cached asset. use cache busting for KP bundles #64414visTypeTimeseries
bundle size #64631 ReducevisTypeMarkdown
bundle size #64638 ReducevisTypeVega
bundle size #64749 Reducelens
bundle size #64769 ReducevisTypeTable
bundle size #64778security
&spaces
plugin bundle sizes #64192maps
bundle size (code splitting) #64317uptime
bundle size #65257The text was updated successfully, but these errors were encountered: