hyperframes icon indicating copy to clipboard operation
hyperframes copied to clipboard

feat(lambda): add real-AWS smoke + benchmark script

Open jrusso1020 opened this issue 6 months ago • 1 comments

What

Adds two local bash scripts under examples/aws-lambda/scripts/ that deploy the PR 6.2 SAM template to your AWS account and exercise the Lambda render path against real fixtures.

  • smoke.sh — one fixture, one or more chunk counts, PSNR-compare against the in-process baseline, tear down. The "did the architecture work end-to-end on real AWS" gate.
  • eval.sh — multiple fixtures, in-process vs Lambda wall-clock comparison, PSNR-compare both against the in-process baseline. The "is Lambda actually faster and visually equivalent" benchmark.

This is PR 6.3 of the 8-PR Phase 6 stack — the last PR of Phase 6a (architecture validation on real AWS). Stacked on top of #879 (PR 6.2: SAM template) and #878 (PR 6.1: handler + ZIP).

Why

PR 6.1 proves BeginFrame works on @sparticuz/chromium inside a Lambda-like Docker container. PR 6.2 produces a deployable SAM template. But neither proves that:

  • the deployed Lambda actually launches Chrome in real Lambda's /tmp
  • the Step Functions Map state actually fans out chunk renders
  • the assembled mp4 actually matches the in-process baseline at PSNR
  • per-stage wall-clock and cost numbers match what we'd expect

smoke.sh is the architectural gate. eval.sh answers the broader "should we use Lambda for this composition?" question by running several fixtures side-by-side with in-process.

Originally drafted as a GitHub Actions workflow (OIDC + repo secrets). Walked back to local scripts: the validation gate is maintainer-run once or twice before a release, not on every PR. Local scripts are simpler — no OIDC, no role trust policy, no cross-account secrets in CI — and run against whatever AWS profile you already have configured.

Eval results (from running this stack)

Fixture Frames Local in-process Lambda (N=4) Speedup PSNR (Lambda vs baseline)
mp4-h264-sdr 60 (2s) 7.1s 12.0s 0.59× (slower) 47.46 dB
many-cuts 168 (5.6s) 25.6s 17.7s 1.44× 37.08 dB
gsap-letters-render-compat 120 (4s) 20.7s 12.0s 1.72× 52.61 dB
heygen-promo-preview-assets 480 (16s) (host err) 63.1s n/a 33.63 dB

Findings:

  • Architecture works end-to-end on real AWS — every fixture produces a valid mp4.
  • Lambda is faster for compositions ≥ ~4 seconds — 1.44-1.72× at N=4 chunks.
  • Tiny compositions (60 frames) are overhead-bound — Lambda is 1.7× slower for 2-second videos. Cold-start + Chrome decompression + S3 round-trip dominate.
  • Visual equivalence: PSNR 33-52 dB across all fixtures. The Docker-baked baseline uses a different ffmpeg + chrome-headless-shell build than Lambda's sparticuz Chromium + ffmpeg-static, so 3-15 dB drift is expected. Lower numbers (33 dB on heygen-promo, 37 dB on many-cuts) come from richer fixtures with sub-comps and audio.

The default eval.sh --psnr-threshold is 40 dB; the OSS regression harness's Docker-vs-Docker check uses 50 dB because the environments match.

Two bugs found and addressed during the eval

  1. PLAN_HASH_MISMATCH on audio-bearing fixtures — plan() left the .plan-work/downloads/*.mp3 temp directory inside planDir while freezePlan() hashed it, then cleaned up afterward. Chunk workers recomputed a different hash. Fixed in PR 6.1 by moving the cleanup before freezePlan. Regression test added to plan.test.ts.

  2. spawn ffprobe ENOENT in Lambda for fixtures using audio pad/trim — ffmpeg-static only ships ffmpeg, not ffprobe. Fixed in PR 6.1 by adding ffprobe-static and staging both binaries.

Usage

# Smoke — one fixture, full architecture gate
./examples/aws-lambda/scripts/smoke.sh

# Eval — multiple fixtures, in-process vs Lambda
./examples/aws-lambda/scripts/eval.sh \
  --fixtures mp4-h264-sdr,many-cuts,gsap-letters-render-compat \
  --chunk-count 4

AWS_PROFILE=<your-profile> ./examples/aws-lambda/scripts/eval.sh

Both scripts deploy a per-run stack name so concurrent runs don't race; both unconditionally tear down (unless --keep-stack). Artifacts land under lambda-smoke-artifacts/ and lambda-eval-artifacts/.

Test plan

  • [x] bash -n — both scripts pass shellcheck-equivalent
  • [x] bunx oxfmt --check — clean
  • [x] Real-AWS smoke run — all 3 chunk counts succeed
  • [x] Real-AWS eval run — 4 fixtures, results above
  • [x] Bugs found in eval (planHash, ffprobe) fixed in PR 6.1 and verified by re-running the eval

🤖 Generated with Claude Code

jrusso1020 avatar May 15 '26 23:05 jrusso1020

[!WARNING] This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

jrusso1020 avatar May 15 '26 23:05 jrusso1020