Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Conversation

brentwilton
Copy link
Contributor

@brentwilton brentwilton commented Nov 22, 2017

Issues

Description

In Windows 10 if parallel: true is set then the parallel worker processes can stall and the build never completes.

The minify request is successfully sent from the plugin to the dist/uglify/worker.js which then minifies the file.

The forked worker returns the result to the plugin via the Node process.send() IPC call, but the parent plugin never receives the request from the worker.
The forked.child.on('message', this.receive.bind(this)) event in worker-farm/lib/farm.js is never invoked which causes the build to stall.

If we change the worker-farm to use maxConcurrentCallsPerWorker: 1 it will prevent the parent from queuing multiple requests via IPC to the workers. It waits until it receives a response from the worker, then it dispatches the next file to minify. This lowers the amount of pending IPC traffic between the plugin and the workers and does not trigger the issue.

Adding this limit will mean that the worker will need to wait for the parent to receive the response before getting a new file to process, but it allows parallel processing to complete on Windows.

Notable Changes

Changes the worker-farm to use { maxConcurrentCallsPerWorker: 1 }.

@jsf-clabot
Copy link

jsf-clabot commented Nov 22, 2017

CLA assistant check
All committers have signed the CLA.

@michael-ciniawsky michael-ciniawsky changed the title fix: set workerFarm maxConcurrentCallsPerWorker to 1 to allow Windows… fix(index): set maxConcurrentCallsPerWorker to 1 (options.parallel) Nov 22, 2017
@michael-ciniawsky michael-ciniawsky added this to the 1.2.1 milestone Nov 22, 2017
Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

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

Thx 👍 Do you know how does this change may affect performance especially on other platforms ? Should we guard this to be set only on windows ?

@brentwilton
Copy link
Contributor Author

On other platforms it will be slightly slower. Approximately (number of output modules) * (plugin worker IPC round trip time) slower.

I can add a guard to make it Windows only.

i.e.

var workerFarmOptions = {
    maxConcurrentWorkers: this.maxConcurrentWorkers,
};
if (os.platform() === 'win32') {
    Object.assign(workerFarmOptions, {
        maxConcurrentCallsPerWorker: 1,
    });
}
this.workers = workerFarm(workerFarmOptions, workerFile);

@michael-ciniawsky
Copy link
Member

Yep, please add a platform check for this e.g

const workerOptions = process.platform === 'win32' ? {...} : {...}

this.workers = workerFarm(workerOptions, workerFile)

Copy link
Member

@joshwiens joshwiens left a comment

Choose a reason for hiding this comment

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

Has there been any root cause analysis as to why this is actually happening.

Uglify issue, ours, Microsofts ? ...

@michael-ciniawsky
Copy link
Member

Has there been any root cause analysis as to why this is actually happening

Not really, I know that the IPC implementation in node for windows/unix(posix) are entirely different due to general OS differences and the windows IPC can behave differently for subtile aspects in case the underlying logic is hard to shim behaving 'the unix way', more details would need further investigation 😅 (maybe good to open an issue in worker-farm or node to clearify)

@StalkAlex
Copy link

StalkAlex commented Mar 3, 2018

This PR is not fully fixing support on Windows, because if I run on BashOnWindows(Ubuntu inside Windows 10) with parallel: true it still hangs.

This condition os.platform() === 'win32' is not correct for BashOnWindows, but maxConcurrentCallsPerWorker: 1 should be set as well as still Windows.

@alexander-akait
Copy link
Member

@StalkAlex can you send PR with reproduce steps?

@StalkAlex
Copy link

StalkAlex commented Mar 3, 2018

@evilebottnawi how such PR could look like?

BashOnWindows

> os.platform()
'linux'
> os.release()
'4.4.0-43-Microsoft'
>

So one should also check for release besides platform.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants