Repository navigation
[ui/bundles][optimizer] only use caches when in dev mode - #15780
Conversation
|
What effect does this have on plugin installation in production? |
|
None. Caches are unique for each plugin combination, so when a plugin is installed the cache is discarded and a new cache is created. Plugin install will be slower if you install a plugin and then uninstall it. |
|
In testing, this might actually be a small improvement to build times. Seeing a 6% reduction in plugin installation for 6.1.1, going from an average installation time of 438 seconds to 410. Might be from the disk IO. |
| getCachePath() { | ||
| return this.resolvePath('../.cache', this.hashBundleEntries()); | ||
| getCacheDirectory(...subPath) { | ||
| if (this.isDevMode()) { |
There was a problem hiding this comment.
Should we add a comment that explains the reasoning here? Maybe something along the lines of
Disabling the cache-loader in the optimizer when running in production mode, as it creates cache files in optimize/.cache that are not necessary for distributable versions of Kibana and just make compressing and extracting it more difficult.
That should hopefully make it easier to remember later on why this was works the way it does
There was a problem hiding this comment.
I appreciate your observation that the relationship between this and the cache loader was not clear, so I think I did a bit better than a comment and put the condition in maybeAddCacheLoader() within BaseOptimizer#getConfig() instead.
|
I believe this should fix the issue mentioned here: https://discuss.elastic.co/t/kibana-6-1-0-starts-with-error/111754 |
7c28e83 to
fbd17e0
Compare
| } | ||
|
|
||
| function maybeAddCacheLoader(uiBundles, cacheName, loaders) { | ||
| // only use cache-loader in dev mode |
There was a problem hiding this comment.
In general I prefer comments that describe why we're doing something, not what is being done. E.g. it's obvious from the line below that we're only adding the cache loader in dev mode, but it's not clear why.
I suggest something like:
/**
* Adds a cache loader if we're running in dev mode. The reason we're not adding
* the cache-loader when running in production mode is that it creates cache
* files in optimize/.cache that are not necessary for distributable versions
* of Kibana and just make compressing and extracting it more difficult.
*/
function maybeAddCacheLoader(uiBundles, cacheName, loaders) {Now I don't have to know the details of the cache-loader to understand why it's excluded in production (in general you'd think caching is something we want in production, so this helps clarify why it's not something we want)
There was a problem hiding this comment.
Alright, that makes total sense. Thanks!
* [ui/bundles][optimizer] only use caches when in dev mode * [optimize/caching] make cache-loader disabling more explicit * [optimize/caching] clarify why we only want caching in dev
… (#15854) * [ui/bundles][optimizer] only use caches when in dev mode * [optimize/caching] make cache-loader disabling more explicit * [optimize/caching] clarify why we only want caching in dev
|
6.2/6.x: a29c6e4 |
* [ui/bundles][optimizer] only use caches when in dev mode * [optimize/caching] make cache-loader disabling more explicit * [optimize/caching] clarify why we only want caching in dev
Fixes #14813 by disabling the
cache-loaders in the optimizer when running in production mode.