mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 17:27:09 +00:00
perf(producer): worker sizing measures screenshot capture, one browser launch fewer (#6630)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user