Skip to content
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

Proper function to calculate number of workers correctly #49

Conversation

mistic
Copy link
Collaborator

@mistic mistic commented Dec 15, 2018

There are some situations when require('os').cpus() will return undefined (nodejs/node#19022).

This PR introduces a function to correctly calculate the number of workers or fallback it to 1 when it is not able to determine the correct number.

\CC @evilebottnawi

@codecov
Copy link

codecov bot commented Dec 15, 2018

Codecov Report

Merging #49 into master will increase coverage by 16.99%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #49       +/-   ##
===========================================
+ Coverage       0%   16.99%   +16.99%     
===========================================
  Files           7        7               
  Lines         372      353       -19     
  Branches       66       58        -8     
===========================================
+ Hits            0       60       +60     
+ Misses        325      261       -64     
+ Partials       47       32       -15
Impacted Files Coverage Δ
src/workerPools.js 0% <0%> (ø) ⬆️
src/worker.js 0% <0%> (ø) ⬆️
src/WorkerError.js 6.25% <0%> (+6.25%) ⬆️
src/WorkerPool.js 20.95% <0%> (+20.95%) ⬆️
src/readBuffer.js 37.5% <0%> (+37.5%) ⬆️
src/index.js 70% <0%> (+70%) ⬆️
src/cjs.js 100% <0%> (+100%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e07fe0e...cd2c497. Read the comment docs.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Good job

src/workerPools.js Outdated Show resolved Hide resolved
@mistic
Copy link
Collaborator Author

mistic commented Dec 17, 2018

@evilebottnawi just applied the suggested simplification!

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

👍

@alexander-akait alexander-akait merged commit fcbd813 into webpack-contrib:master Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants