mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-08 15:08:27 -05:00
feat: use availableParallelism get the amount of paralllelism available (#7304)
This commit is contained in:
6
.changeset/breezy-dragons-drive.md
Normal file
6
.changeset/breezy-dragons-drive.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/package-requester": patch
|
||||
"@pnpm/worker": patch
|
||||
---
|
||||
|
||||
Use availableParallelism, when available.
|
||||
@@ -101,7 +101,8 @@ export function createPackageRequester (
|
||||
// A lower bound of 16 is enforced to prevent performance degradation,
|
||||
// especially in CI environments. Tests with a threshold lower than 16
|
||||
// have shown consistent underperformance.
|
||||
const networkConcurrency = opts.networkConcurrency ?? Math.max(os.cpus().length, 16)
|
||||
// @ts-expect-error - `availableParallelism` is not exist until update @types/node to v18.14.5
|
||||
const networkConcurrency = opts.networkConcurrency ?? Math.max(os.availableParallelism?.() ?? os.cpus().length, 16)
|
||||
const requestsQueue = new PQueue({
|
||||
concurrency: networkConcurrency,
|
||||
})
|
||||
|
||||
@@ -26,7 +26,8 @@ export async function finishWorkers () {
|
||||
}
|
||||
|
||||
function createTarballWorkerPool (): WorkerPool {
|
||||
const maxWorkers = Math.max(2, os.cpus().length - Math.abs(process.env.PNPM_WORKERS ? parseInt(process.env.PNPM_WORKERS) : 0)) - 1
|
||||
// @ts-expect-error - `availableParallelism` is not exist until update @types/node to v18.14.5
|
||||
const maxWorkers = Math.max(2, (os.availableParallelism?.() ?? os.cpus().length) - Math.abs(process.env.PNPM_WORKERS ? parseInt(process.env.PNPM_WORKERS) : 0)) - 1
|
||||
const workerPool = new WorkerPool({
|
||||
id: 'pnpm',
|
||||
maxWorkers,
|
||||
|
||||
Reference in New Issue
Block a user