Skip to content

Commit

Permalink
fix: always use half of available parallelism (#611)
Browse files Browse the repository at this point in the history
* fix: always use half of available parallelism

* fix fallback docs

* revert docs

* tweak logic
  • Loading branch information
mrazauskas authored Jul 27, 2024
1 parent 219f075 commit 4c3f289
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/polyfills/cpus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import {

export const availableParallelism = (): number =>
typeof nodeAvailableParallelism === 'function'
? Math.floor(nodeAvailableParallelism() / 2)
: (cpus()?.length ?? 1);
? nodeAvailableParallelism()
: (cpus()?.length ?? 0);
3 changes: 2 additions & 1 deletion src/services/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export const runTestsParallel = async (
? [sanitizePath(dir)]
: await listFiles(testDir, configs);
const filesByConcurrency: string[][] = [];
const concurrencyLimit = configs?.concurrency ?? availableParallelism();
const concurrencyLimit =
configs?.concurrency ?? Math.max(Math.floor(availableParallelism() / 2), 1);
const concurrencyResults: (boolean | undefined)[][] = [];
const showLogs = !isQuiet(configs);

Expand Down
3 changes: 2 additions & 1 deletion website/docs/documentation/poku/options/concurrency.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ sidebar_position: 8
# `concurrency`

When using `parallel` option, use `concurrency` to limit the number of tests running concurrently.<br />
The default value is `0` (no limit).
The default value is half of the available cores. When available, the `os.availableParallelism()` method is used. Otherwise Poku looks at the `os.cpus().length` or sets the value to `1`.<br />
To allow unlimited parallelism set the value to `0`.

## CLI

Expand Down

0 comments on commit 4c3f289

Please sign in to comment.