Skip to content

Commit e05debe

Browse files
fix(engine): honor explicit render worker counts (#2439)
1 parent 89db718 commit e05debe

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎packages/engine/src/services/parallelCoordinator.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ describe("calculateOptimalWorkers", () => {
7676

7777
expect(workers).toBe(4);
7878
});
79+
80+
it.each([12, 16])(
81+
"honors an explicit %i-worker request above the auto safe maximum",
82+
(requested) => {
83+
expect(calculateOptimalWorkers(900, requested, { concurrency: "auto" })).toBe(requested);
84+
},
85+
);
86+
87+
it("caps explicit worker requests at the documented 24-worker ceiling", () => {
88+
expect(calculateOptimalWorkers(900, 25, { concurrency: "auto" })).toBe(24);
89+
});
7990
});
8091

8192
describe("shouldDisableBrowserPoolForParallelWorker", () => {

‎packages/engine/src/services/parallelCoordinator.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ export function calculateOptimalWorkers(
160160
requested?: number,
161161
config?: WorkerSizingConfig,
162162
): number {
163+
if (requested !== undefined) {
164+
return Math.max(MIN_WORKERS, Math.min(ABSOLUTE_MAX_WORKERS, requested));
165+
}
166+
163167
// Resolve effective values: config overrides → DEFAULT_CONFIG fallback.
164168
const effectiveMaxWorkers = (() => {
165169
const concurrency = config?.concurrency ?? DEFAULT_CONFIG.concurrency;
@@ -174,10 +178,6 @@ export function calculateOptimalWorkers(
174178
config?.largeRenderThreshold ?? DEFAULT_CONFIG.largeRenderThreshold;
175179
const captureCostMultiplier = Math.max(1, config?.captureCostMultiplier ?? 1);
176180

177-
if (requested !== undefined) {
178-
return Math.max(MIN_WORKERS, Math.min(effectiveMaxWorkers, requested));
179-
}
180-
181181
if (totalFrames < MIN_FRAMES_PER_WORKER * 2) return 1;
182182

183183
const cpuCount = cpus().length;

0 commit comments

Comments
 (0)