-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[optimizer] More aggressive chunking of common/vendor code #15816
Conversation
src/optimize/base_optimizer.js
Outdated
}), | ||
|
||
new NoEmitOnErrorsPlugin(), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be vendors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, missed it when I changed from vendor
to vendors
.
a4c83ef
to
8c71e7e
Compare
Previously, we were not aggressive in combining common code which resulted in duplicates included in the bundles. As an example `node_modules/elasticsearch-browser/elasticsearch.angular.js` is present in the following chunks: * kibana.bundle.js * dashboardViewer.bundle.js * apm.bundle.js * monitoring.bundle.js * ml.bundle.js * timelion.bundle.js * graph.bundle.js Vendored code (anything inside node_modules) is placed in vendors.bundle.js while everything else with more than two references is placed in commons.bundle.js. This has a couple positive side-effects (numbers are with x-pack & canvas): * Decreased build time. Seeing builds go from 475.76 seconds to 274.72. * Decreased memory overhead. Uses roughly 1/3 the memory overhead. * Decreased bundle size. A 68% reduction in overall bundle size. Going from 66.16 MB to 21.13 MB. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
8c71e7e
to
e3aca1c
Compare
This is looking great! Do you know if it's simple/possible to split up the vendors file? I’m not too versed in parse times, but I think ~11MB might take in the range of 2-4 seconds to parse in Chrome and Firefox on a brand new Macbook Pro. This is from the latest Kibana release when loading the current 10MB kibana.bundle.js: (Given we're already on 10MB today, moving to 11MB likely isn't a problem in the short-term as this change is giving us a couple essential wins, but it's probably something we want to explore more later) |
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change looks good to me and it seems to improve the dev experience 💯
@tylersmalley help me understand how
improves things? |
@archanid, if there is code required in Kibana and X-Pack that code will be placed in commons instead of duplicated in both entry points. |
With no custom optimize rules: Seems to work with both x-pack and canvas running. I'm not running into the memory problems like before, and build time is around 260 seconds. A couple of notes:
With custom optimize rules: Using the following in my kibana.yml, I hit the OOM issue without the memory flag (crashed at ~1.4gb) optimize:
lazy: true
lazyPrebuild: false
unsafeCache: true
profile: true
sourceMaps: "#cheap-source-map" |
Sourcemaps work fine, I loaded another plugin from the template, and even running that, the canvas extras, canvas, and x-pack, everything seems to be working correctly. And I'm not hitting OOM issues, even when using `#cheap-module-eval-source-map`. I still see all those `.map` files, but apparently that's expected after all.
No idea what changed, but it's not the first time sourcemaps have been flaky for me...
Built x-pack, canvas, canvas-extras, and a generated plugin in 161 seconds, with the following in my kibana.dev.yml, without issue, and the sourcemaps work great.
**kibana.dev.yml**
```yml
optimize:
lazy: true
lazyPrebuild: false
sourceMaps: "#cheap-module-eval-source-map"
``` |
LGTM |
Tried doing a "production" install on my machine with 6.1.2 snapshots.
Never ran into any OOM issues either. There's a problem running canvas, but I'm pretty sure it's not a new problem. Otherwise, it looks like everything else is working as expected. I can't speak to the webpack changes, I'm not well versed enough, but functionally, this PR LGTM. |
Previously, we were not aggressive in combining common code which resulted in duplicates included in the bundles. As an example `node_modules/elasticsearch-browser/elasticsearch.angular.js` is present in the following chunks: * kibana.bundle.js * dashboardViewer.bundle.js * apm.bundle.js * monitoring.bundle.js * ml.bundle.js * timelion.bundle.js * graph.bundle.js Vendor code (anything inside Kibana's node_modules) is placed in vendors.bundle.js while everything else with more than two references is placed in commons.bundle.js. This has a couple positive side-effects (numbers are with x-pack & canvas): * Decreased build time. Seeing builds go from 475.76 seconds to 274.72. * Decreased memory overhead. Uses roughly 1/3 the memory overhead. * Decreased bundle size. A 68% reduction in overall bundle size. Going from 66.16 MB to 21.13 MB. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
6.2/6.x: 303f98a |
@tylersmalley Since this has impacts on production builds, can you label accordingly so it appears in release notes? |
…lastic#15816)" This reverts commit 92b373b.
This ended up breaking x-pack ci, so it has been reverted until we can figure out what changed for plugins. |
…lastic#15816)" (elastic#15878) This reverts commit 92b373b.
Previously, we were not aggressive in combining common code which resulted in duplicates included in the bundles.
As an example
node_modules/elasticsearch-browser/elasticsearch.angular.js
is present in the following chunks:Vendor code (anything inside Kibana's node_modules) is placed in vendors.bundle.js while everything else with more than two references is placed in commons.bundle.js.
This has a couple positive side-effects (numbers are with x-pack & canvas):
Release Note: Improved the build optimize time by more aggressively chunking common code, resulting in the removal of duplicate code. This drastically cuts the build and plugin install time and overall bundle asset size.