-
Notifications
You must be signed in to change notification settings - Fork 10.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
always assume at least one cpu #6484
Conversation
Deploy preview for using-drupal ready! Built with commit 7c70937 |
Deploy preview for gatsbygram ready! Built with commit 7c70937 |
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!
I wonder if we should provide way to set this up in config and add warning that Gatsby can't determine core count |
Yeah, maybe have a way to set the worker count or something via an env variable. I am surprised though that it doesn't work on Alpine Linux (what @jquense reported on Discord) |
I was gonna check the npm package source, but its not on github that I can find...I'm sure there is a more robust way to handle this but i have no idea... |
This is the code in node_modules 'use strict'
const os = require('os')
const childProcess = require('child_process')
function exec (command) {
const output = childProcess.execSync(command, {encoding: 'utf8'})
return output
}
let amount
const platform = os.platform()
if (platform === 'linux') {
const output = exec('lscpu -p | egrep -v "^#" | sort -u -t, -k 2,4 | wc -l')
amount = parseInt(output.trim(), 10)
} else if (platform === 'darwin') {
const output = exec('sysctl -n hw.physicalcpu_max')
amount = parseInt(output.trim(), 10)
} else if (platform === 'windows') {
const output = exec('WMIC CPU Get NumberOfCores')
amount = output.split(os.EOL)
.map(function parse (line) { return parseInt(line) })
.filter(function numbers (value) { return !isNaN(value) })
.reduce(function add (sum, number) { return sum + number }, 0)
} else {
const cores = os.cpus().filter(function (cpu, index) {
const hasHyperthreading = cpu.model.includes('Intel')
const isOdd = index % 2 === 1
return !hasHyperthreading || isOdd
})
amount = cores.length
}
module.exports = amount |
o maybe it should fallback to that last branch? |
Yeah, if |
Weird the package isn't on github. |
https://gitlab.com/sebdeckers/physical-cpu-count/ I was just bit by that, testing the new https://zeit.co/blog/dockerfile-static UPDATE: fixed URL |
My workaround was to add this to my Alpine
|
"version": "2.0.0-beta.38", but I see beta.44 was released. Usually, I will remove my workaround and give the new version a go. |
Indeed, that worked flawlessly, thanks! |
alpine doesn't come with
lscpu
so the cpu check fails, reporting 0, meaning no pages are written out