(envVal: string | undefined, cpuCount: number)
| 143 | } |
| 144 | |
| 145 | export function resolveParsePoolSize(envVal: string | undefined, cpuCount: number): number { |
| 146 | if (envVal !== undefined && envVal !== '') { |
| 147 | const n = Number(envVal); |
| 148 | if (Number.isFinite(n) && n >= 0) { |
| 149 | return Math.max(1, Math.min(Math.floor(n), MAX_PARSE_POOL_SIZE)); |
| 150 | } |
| 151 | // non-numeric / negative → fall through to the default |
| 152 | } |
| 153 | return Math.max(1, Math.min(cpuCount - 1, DEFAULT_PARSE_POOL_CAP)); |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * How many workers `parseMs` of parsing is worth. W workers take parseMs / W, |
no test coverage detected