(envVal: string | undefined, cpuCount: number)
| 118 | * the main thread + UI; never zero — parsing always needs a worker). |
| 119 | */ |
| 120 | export function resolveParsePoolSize(envVal: string | undefined, cpuCount: number): number { |
| 121 | if (envVal !== undefined && envVal !== '') { |
| 122 | const n = Number(envVal); |
| 123 | if (Number.isFinite(n) && n >= 0) { |
| 124 | return Math.max(1, Math.min(Math.floor(n), MAX_PARSE_POOL_SIZE)); |
| 125 | } |
| 126 | // non-numeric / negative → fall through to the default |
| 127 | } |
| 128 | return Math.max(1, Math.min(cpuCount - 1, DEFAULT_PARSE_POOL_CAP)); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * How many workers `parseMs` of parsing is worth. W workers take parseMs / W, |
no test coverage detected