Skip to content

Commit

Permalink
Merge pull request #143 from twlite/patch-2
Browse files Browse the repository at this point in the history
fix(processConcurrency): improve process concurrency count
  • Loading branch information
yamadashy authored Oct 30, 2024
2 parents 2ced938 + 60694ee commit 603ecc8
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/shared/processConcurrency.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import os from 'node:os';

export const getProcessConcurrency = () => {
const cpuCount = os.cpus().length;

// Fallback for environments where os.cpus().length returns 0
// see: https://github.com/yamadashy/repopack/issues/56
if (cpuCount === 0) {
return 1;
}
const cpuCount = typeof os.availableParallelism === 'function' ? os.availableParallelism() : os.cpus().length;

// Use all available CPUs except one
return Math.max(1, cpuCount - 1);
Expand Down

0 comments on commit 603ecc8

Please sign in to comment.