Skip to content

feat(producer): fan out capture across Cloudflare Sandboxes - #3260

Draft
tombeckenham wants to merge 1 commit into
heygen-com:mainfrom
tombeckenham:feat/cloudflare-sandbox-distributed-render
Draft

feat(producer): fan out capture across Cloudflare Sandboxes#3260
tombeckenham wants to merge 1 commit into
heygen-com:mainfrom
tombeckenham:feat/cloudflare-sandbox-distributed-render

Conversation

@tombeckenham

Copy link
Copy Markdown

What

Add a Cloudflare Sandbox adapter that fans heygen-promo-preview-assets capture across up to 10 isolated software-GL Chromes, plus a bench harness that measures wall-clock against the frozen producer baseline.

Why

Local --workers N shares one SwiftShader and was slower on this fixture (+6.4% at 3 workers). Isolated remotes are the path that can actually cut wall-clock. Goal: beat 190,283 ms by 25% (≤ 142,712 ms).

How

Thin wrapper around the existing planrenderChunk × N → assemble primitives. Custom sandbox image (Chrome headless-shell + FFmpeg + Bun). Fleet pinned to account 86bb57b655af7915f42b29dfc2d8807d, max_instances: 10, instance_type: standard-3. Plan runs remotely so FFmpeg versions match. Not the default local hyperframes render path.

standard-2 (1 vCPU) missed the bar (~239s). standard-3 (2 vCPU) 3-run average 101,587 ms (−46.6%). PSNR 42.7–48.1 dB (bar 30).

Test plan

  • Unit tests added/updated (cloudflareSandbox.test.ts — account pin, wrangler cap, resolveChunkPlan(480), mocked planrenderChunk × N → assemble)
  • Manual testing performed (3-run sandbox bench vs golden PSNR)
  • Documentation updated (tests/perf/goal.md, tests/perf/README.md)

To reproduce:

cd packages/producer
bun test src/services/distributed/cloudflareSandbox.test.ts
HF_SANDBOX_URL=$HF_SANDBOX_URL bun src/cloudflareSandboxBench.ts --runs 3 \
  --fixture tests/heygen-promo-preview-assets/src

Isolated remote Chromes beat the 25% wall-clock goal; extra local
workers share one SwiftShader and get slower.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant