perf(producer): worker sizing measures screenshot capture, one browser launch fewer (#6630)

This commit is contained in:
Miguel Ángel
2026-10-28 07:24:34 +00:00
committed by GitHub
parent dd7290ae83
commit 2b6d176452
2 changed files with 36 additions and 1 deletions
@@ -55,6 +55,7 @@ import {
resolveAdaptersUsed,
resolveDeShortBand,
shouldClampDefaultDrawElement,
calibrationCaptureConfig,
shouldPreferParallelDrawElement,
shouldPreferSingleWorkerDrawElement,
isCaptureParallelStreamRouterEnabled,
@@ -3638,6 +3639,22 @@ describe("shouldStreamParallelCapture (non-DE parallel streaming router)", () =>
});
});
describe("calibrationCaptureConfig", () => {
const drawElementCfg = () => ({ ...createConfig(), useDrawElement: true });
it("measures screenshot capture, the mode parallel workers use", () => {
const cfg = drawElementCfg();
expect(calibrationCaptureConfig(cfg, {}).useDrawElement).toBe(false);
expect(cfg.useDrawElement).toBe(true);
});
it("keeps drawElement when parallel drawElement was opted into", () => {
const cfg = drawElementCfg();
expect(calibrationCaptureConfig(cfg, { PRODUCER_EXPERIMENTAL_FAST_CAPTURE: "true" })).toBe(cfg);
expect(calibrationCaptureConfig(cfg, { HF_DE_PARALLEL_STREAM: "true" })).toBe(cfg);
});
});
describe("shouldClampDefaultDrawElement (default-on drawElement clamp)", () => {
const unverifiedParallel = {
useDrawElement: true,
@@ -2842,6 +2842,24 @@ export function shouldClampDefaultDrawElement(args: {
);
}
/**
* Calibration sizes a parallel render, and parallel workers capture by screenshot
* unless drawElement was opted into: measure that mode, without a drawElement init.
*/
export function calibrationCaptureConfig(
cfg: EngineConfig,
env: NodeJS.ProcessEnv = process.env,
): EngineConfig {
const parallelKeepsDrawElement = !shouldClampDefaultDrawElement({
useDrawElement: cfg.useDrawElement,
fastCaptureExplicitOptIn: env.PRODUCER_EXPERIMENTAL_FAST_CAPTURE === "true",
useStreamingEncode: true,
workerCount: 2,
deParallelStreamVerified: env.HF_DE_PARALLEL_STREAM === "true",
});
return parallelKeepsDrawElement ? cfg : { ...cfg, useDrawElement: false };
}
export function resolveCaptureForceScreenshotForPageSideCompositing(args: {
forceScreenshot: boolean;
usePageSideCompositing: boolean;
@@ -4011,7 +4029,7 @@ async function executeRenderPipeline(input: {
}),
() =>
runCaptureCalibration({
cfg,
cfg: calibrationCaptureConfig(cfg),
fileServer: activeFileServer,
workDir,
log,