Files
deepseek-harness/scripts/parallelism.spec.ts
T
imccyu ed7bf8cc42 perf(gates): cap local default worker counts
os.availableParallelism() reports host CPUs rather than a container's
CPU quota (256 against a 64-CPU quota here), so local defaults spawned
255 Vitest forks (55 GiB peak RSS) and oversubscribed every scheduler.
scripts/parallelism.ts keeps the CPU count in CI and caps other runs at
12, or 48 for Vitest forks and the local coverage budget; documentation
and hygiene aggregates run up to 8 gates instead of 4. Explicit
DSH_GATE_CONCURRENCY, DSH_OXLINT_THREADS, DSH_COVERAGE_MAX_WORKERS, and
--maxWorkers still win.

Refs #5852
2026-10-12 11:06:50 +08:00

24 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { LOCAL_PARALLELISM_CAP, LOCAL_TEST_PARALLELISM_CAP, defaultParallelism, describeDefaultParallelism } from './parallelism.ts'
describe('default worker budget', () => {
it('uses every reported CPU in CI', () => {
expect(defaultParallelism({ CI: 'true' }, 256)).toBe(256)
expect(describeDefaultParallelism({ CI: 'true' }, 16)).toBe('16 available CPU(s)')
})
it('caps local runs without exceeding the reported CPUs', () => {
expect(LOCAL_PARALLELISM_CAP).toBe(12)
expect(defaultParallelism({}, 256)).toBe(12)
expect(defaultParallelism({ CI: 'false' }, 256)).toBe(12)
expect(defaultParallelism({}, 4)).toBe(4)
expect(describeDefaultParallelism({}, 256)).toBe('12 local default worker(s) of 256 CPU(s)')
})
it('lets Vitest forks use a larger local cap', () => {
expect(LOCAL_TEST_PARALLELISM_CAP).toBe(48)
expect(defaultParallelism({}, 256, LOCAL_TEST_PARALLELISM_CAP)).toBe(48)
expect(defaultParallelism({ CI: 'true' }, 256, LOCAL_TEST_PARALLELISM_CAP)).toBe(256)
})
})