File tree Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Expand file tree Collapse file tree 3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 11import { MessageChannel } from 'node:worker_threads'
2- import { cpus } from 'node:os'
2+ import * as nodeos from 'node:os'
33import { pathToFileURL } from 'node:url'
44import { createBirpc } from 'birpc'
55import { resolve } from 'pathe'
@@ -39,9 +39,14 @@ function createWorkerChannel(project: WorkspaceProject) {
3939}
4040
4141export function createThreadsPool ( ctx : Vitest , { execArgv, env } : PoolProcessOptions ) : ProcessPool {
42+ const numCpus
43+ = typeof nodeos . availableParallelism === 'function'
44+ ? nodeos . availableParallelism ( )
45+ : nodeos . cpus ( ) . length
46+
4247 const threadsCount = ctx . config . watch
43- ? Math . max ( Math . floor ( cpus ( ) . length / 2 ) , 1 )
44- : Math . max ( cpus ( ) . length - 1 , 1 )
48+ ? Math . max ( Math . floor ( numCpus / 2 ) , 1 )
49+ : Math . max ( numCpus - 1 , 1 )
4550
4651 const maxThreads = ctx . config . maxThreads ?? threadsCount
4752 const minThreads = ctx . config . minThreads ?? threadsCount
Original file line number Diff line number Diff line change 11import { MessageChannel } from 'node:worker_threads'
2- import { cpus } from 'node:os'
2+ import * as nodeos from 'node:os'
33import { pathToFileURL } from 'node:url'
44import { createBirpc } from 'birpc'
55import { resolve } from 'pathe'
@@ -40,9 +40,14 @@ function createWorkerChannel(project: WorkspaceProject) {
4040}
4141
4242export function createVmThreadsPool ( ctx : Vitest , { execArgv, env } : PoolProcessOptions ) : ProcessPool {
43+ const numCpus
44+ = typeof nodeos . availableParallelism === 'function'
45+ ? nodeos . availableParallelism ( )
46+ : nodeos . cpus ( ) . length
47+
4348 const threadsCount = ctx . config . watch
44- ? Math . max ( Math . floor ( cpus ( ) . length / 2 ) , 1 )
45- : Math . max ( cpus ( ) . length - 1 , 1 )
49+ ? Math . max ( Math . floor ( numCpus / 2 ) , 1 )
50+ : Math . max ( numCpus - 1 , 1 )
4651
4752 const maxThreads = ctx . config . maxThreads ?? threadsCount
4853 const minThreads = ctx . config . minThreads ?? threadsCount
Original file line number Diff line number Diff line change 55 * LICENSE file in the root directory of facebook/jest GitHub project tree.
66 */
77
8- import { cpus } from 'node:os'
8+ import * as nodeos from 'node:os'
99import type { ResolvedConfig } from '../types'
1010
1111function getDefaultThreadsCount ( config : ResolvedConfig ) {
12+ const numCpus
13+ = typeof nodeos . availableParallelism === 'function'
14+ ? nodeos . availableParallelism ( )
15+ : nodeos . cpus ( ) . length
16+
1217 return config . watch
13- ? Math . max ( Math . floor ( cpus ( ) . length / 2 ) , 1 )
14- : Math . max ( cpus ( ) . length - 1 , 1 )
18+ ? Math . max ( Math . floor ( numCpus / 2 ) , 1 )
19+ : Math . max ( numCpus - 1 , 1 )
1520}
1621
1722export function getWorkerMemoryLimit ( config : ResolvedConfig ) {
You can’t perform that action at this time.
0 commit comments