-
-
Notifications
You must be signed in to change notification settings - Fork 178
refactor: split cache and parallel options
#108
Conversation
michael-ciniawsky
left a comment
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.
👍 Only unrelated nits and one question :)
| @@ -1,10 +1,9 @@ | |||
| import os from 'os'; | |||
| import cacache from 'cacache'; | |||
| import findCacheDir from 'find-cache-dir'; | |||
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.
findCacheDir => cacheDir
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.
cacheDir sounds like the result of findCacheDir
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.
@Kovensky @michael-ciniawsky let's rename, thanks!
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.
@Kovensky It is a {Function} which 'contains' the value =>
- Directly pass as an argument with 'higher order' =>
const cache = (data, cacheDir(options)) => cache - Assign it to a scope/block/'namespace' instead of an 'redundant' variable
this.cacheDir = cacheDir(options) // ok
const cache = { data, dir: cacheDir(options) } // ok
const cacheDir = findCacheDir(options) // unnecessary :DAnyways just a nitpick 🐦 😛
| @@ -1,10 +1,9 @@ | |||
| import os from 'os'; | |||
| import cacache from 'cacache'; | |||
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.
cacache => cache
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.
@michael-ciniawsky i think rename can be misleading, we can use cache variable for other purpose. Also i think it is bad practice, but if someone from the reviewers considers renaming a good practice, say it here and I do it 😄
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.
I'd suggest that if it's renamed, we don't go with cache as that's used all over the place in webpack already which may / may not be confusing.
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.
I would stay with cacache as name. name is usual equal to package name.
| @@ -1,30 +0,0 @@ | |||
| import crypto from 'crypto'; | |||
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.
Is the caching sufficiently tested elsewhere in the tests ?
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.
@michael-ciniawsky be good add more tests, but cache.test.js doesn't test caching (just test get and put function)
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.
let's add more tests
uglify options and version (options.parallel.cache)
00d75bb to
d2ac477
Compare
uglify options and version (options.parallel.cache)cache and parallel options
e700839 to
cc3d49f
Compare
|
@michael-ciniawsky @hulkish @bebraw @d3viant0ne friendly ping
|
This happend for me locally when I didn't build the |
michael-ciniawsky
left a comment
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.
options.parallel.cache => options.cache is a breaking change 😞
|
@michael-ciniawsky we have |
cc3d49f to
e22ee39
Compare
|
Yeah it's not optimal, but the |
|
For reference, we can publish alpha / beta builds directly from this branch. Once everyone is satisfied (enough) with it, we can push a beta for the next semver:Major & get Sean to put it out on blast via Twitter. That has the side effect of making it easier to test the changes in the major integrations ( @angular/cli & create-react-app ) |
|
Can we merge this PR and work on a solution for #120 ? Is it possible to rebase the current
|
cache and parallel optionscache and parallel options
|
@d3viant0ne @hulkish friendly ping |
sokra
left a comment
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.
I didn't check the tests, but changes make sense to me
| @@ -1,10 +1,9 @@ | |||
| import os from 'os'; | |||
| import cacache from 'cacache'; | |||
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.
I would stay with cacache as name. name is usual equal to package name.
| constructor(options = {}) { | ||
| const { cache, parallel } = options; | ||
| this.cacheDir = cache === true ? findCacheDir({ name: 'uglifyjs-webpack-plugin' }) : cache; | ||
| this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1); |
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.
Is there a reason why only using cpu count - 1? Why not using all CPUs?
I would replace Math.min(Number(parallel) || 0, os.cpus().length - 1) with Number(parallel) || 0. When the user chooses a worker count we should respect it, even if it's more than CPUs.
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.
@sokra -1 - one for master other for childs
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.
Yep one core needs to be reserved for the main process running the worker farm
| put(this.cache, task.cacheKey, data, cacheIdentifier).then(done, done); | ||
|
|
||
| if (this.cacheDir && !result.error) { | ||
| cacache.put(this.cacheDir, task.cacheKey, JSON.stringify(data)).then(done, done); |
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.
Does it make sense to move the cache put operation into the worker process?
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.
@sokra no sense
|
@evilebottnawi - This in a place where you are ready for a beta build out to npm? |
|
@d3viant0ne yep |
|
why not merge this pr? some of my project in window system doesn't work now. TT |
|
@Genuifx - It will merge when we are satisfied with it's stability. In the mean time, there are beta builds available on npm for this branch with the latest being |
|
@d3viant0ne copy that. |
|
@Genuifx feedback welcome 👍 |
|
@evilebottnawi - Updated defaults & the npm 5 / Node 4.3 issue. One the snapshots are sorted, i'd like to put out a final beta build & get this finished up this week if possible. |
We have been using beta3 at work (Hipmunk) for a few days and have not experienced any issue yet. This represent around 100 build. |
Notable Changes
cacheandparalleloptions, because they should not be tied up. I can enablecachebut disableparallel, also i can enableparallelbut disablecache. Seems we were not too careful when we were accepted PR withparalleloption.paralleldoesn't work as expected ([v1.0.0-beta.2] parallelization isn't working #97).cache,parallel,ecma-8,ecma-7,ecma-6ecma-5). Remove unnecessary extra tests fromparalleltests.src/uglify/cache.js, usecacachedirectly instead.cacheIdentifier(akametadata) field for invalidate cache becausemetadatashould be used for other purposes (examplemetadatahttps://github.com/zkat/cacache#example-2). For invalidate cache we should usecacheKey.uglify-eswas updated.uglifyjs-webpack-pluginwas updated.optionsfor plugin was changed (we can't use onlyuglifyOptionsbecause we can changeextractCommentsorwarningsFilteroptions). Maybe we can exclude some options not affecting on cache (test,include,exclude,parallelandsourceMap). Awaiting feedback.Issues
Fix #100
Fix #97
One strange behavior
I remove
[chunkhash]inecma.test.jsbecausewebpackgenerate difference[chunkhash]forecma-5on node4and8, I don't know why :/