Skip to content

Commit f15b79a

Browse files
fix: cpu concurrency detection on some platforms (#3255)
`os.availableParallelism()` should produce more accurate results of how much parallelism should be used then `os.cpus().length`. The only breaking change is the newer API requires node versions >= v18.x which is fine as node-gyp only aims to support latest and LTS releases. And the oldest LTS release still supported as of this commit is v22. Fixes #3191
1 parent 6c2e374 commit f15b79a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function build (gyp, argv) {
163163
if (!isNaN(j) && j > 0) {
164164
argv.push('/m:' + j)
165165
} else if (jobs.toUpperCase() === 'MAX') {
166-
argv.push('/m:' + require('os').cpus().length)
166+
argv.push('/m:' + require('os').availableParallelism())
167167
}
168168
}
169169
} else {
@@ -178,7 +178,7 @@ async function build (gyp, argv) {
178178
argv.push(j)
179179
} else if (jobs.toUpperCase() === 'MAX') {
180180
argv.push('--jobs')
181-
argv.push(require('os').cpus().length)
181+
argv.push(require('os').availableParallelism())
182182
}
183183
}
184184
}

0 commit comments

Comments
 (0)