Skip to content

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

Merged
jrusso1020 merged 3 commits into
mainfrom
06-3-feat_lambda_real_aws_smoke_workflow
May 16, 2026
Merged

feat(lambda): add real-AWS smoke + benchmark script#908
jrusso1020 merged 3 commits into
mainfrom
06-3-feat_lambda_real_aws_smoke_workflow

Conversation

@jrusso1020
Copy link
Copy Markdown
Collaborator

Summary

Recreated after #880 was auto-closed when its base branch (#879/#907's branch) was deleted on merge. Same content (3 commits), rebased onto post-#878 + post-#907 main.

  • examples/aws-lambda/scripts/smoke.sh — real-AWS smoke + benchmark for a single fixture across multiple chunk counts. Builds the handler ZIP, deploys the SAM stack, runs Step Functions executions, PSNR-compares against the in-process baseline, tears down.
  • examples/aws-lambda/scripts/eval.sh — wider benchmark across the producer regression fixtures. Local-in-process vs Lambda speedup + PSNR + audio residual-RMS gate.

Carries over all review feedback addressed in #880 (Vai + Magi approved):

  • eval.sh PSNR gate fixed (process-substitution form so FAILED mutations stick).
  • trap 'cleanup_and_exit \$?' EXIT on both scripts so unrouted failures don't leak CFN + S3.
  • amix normalize=0 so residual-RMS reading isn't 6 dB low.
  • Wall-clock methodology bias documented inline + in README.
  • --iterations N flag + median wall-clock for stable readings.
  • --reserved-concurrency flag + cost-per-pass README documentation.
  • sed -n '2,30p' heredoc fix; RMS-level regex fallback for old ffmpeg builds.
  • Internal plan-doc refs scrubbed.

Testing

Replaces #880 (auto-closed when base branch was deleted on #907 merge).

Phase 6.3 of the distributed rendering plan
(DISTRIBUTED-RENDERING-PLAN.md §11 Phase 6a). Local bash script that
deploys the PR 6.2 SAM template to your own AWS account, renders a
fixture composition through the Step Functions state machine at several
chunk counts, PSNR-compares each output against the in-process
baseline, and tears the stack down.

This is the gate that proves the architecture works on real Lambda
infrastructure. After it runs green and the numbers are good, Phase 6b
(CLI, CDK, docs) can proceed with confidence.

Script lives at examples/aws-lambda/scripts/smoke.sh. Defaults:
  - fixture:        mp4-h264-sdr
  - chunk_counts:   2,4,8
  - psnr-threshold: 50 dB
  - region:         us-east-1
  - stack-name:     hyperframes-lambda-smoke-<timestamp>

AWS credentials come from the standard resolution chain (env vars,
~/.aws/credentials, SSO, IMDS). Pin a specific profile via --profile or
AWS_PROFILE; the script doesn't ship a default.

Workflow:
  1. Pre-flight: verify aws/sam/bun/ffmpeg/jq/zip on PATH; check
     credentials via sts:GetCallerIdentity.
  2. Build the PR 6.1 ZIP and run verify:zip-size.
  3. sam validate --lint + sam deploy under a per-run stack name.
  4. Zip the fixture's src/ and upload to the render bucket.
  5. For each chunk count, start a Step Functions execution, poll for
     completion (25-min cap), download the output mp4 and the execution
     history JSON, ffmpeg-psnr against the LFS-tracked in-process
     baseline, and append to results.json.
  6. Gate on the PSNR threshold.
  7. Empty the bucket + sam delete (unless --keep-stack).

Outputs land under ./lambda-smoke-artifacts/:
  - results.json (chunkCount x wallClockMs x psnrAvgDb)
  - renders/N<N>-output.mp4
  - renders/N<N>-history.json (full Step Functions execution history)

Per-run stack name with concurrency-safe AWS resource isolation. Run
multiple smokes in parallel without races; teardown guards against
stale stacks via cleanup_and_exit on every failure path.

Distinction from CI: this is a maintainer-run gate, not part of regular
CI. The architecture's per-PR safety net is the local Docker-based
BeginFrame probe (PR 6.1) and the upcoming Lambda RIE smoke mode (PR
6.6). No GitHub Actions / OIDC / cross-account secrets required.

This is part of the 8-PR Phase 6 stack; PR 6.3 of 8 — the last PR of
Phase 6a (validation). Phase 6b (CLI + CDK + docs) starts once 6.3's
benchmark numbers come back.
- Document wall-clock methodology bias inline (eval.sh header + README):
  local timing includes bun + tsx + harness scaffolding while Lambda
  timing measures pure SFN execution, so "speedup" is end-to-end CLI
  experience, not renderer-vs-renderer.
- Add --iterations N (default 1) with median wall-clock reporting via
  awk-side median. Cold-start variance is ±5-10s per chunk; single-
  sample readings made the PR-body speedup table not ground truth.
- Add --reserved-concurrency flag to both scripts; default still 16 but
  no longer hardcoded. Pass-through to ReservedConcurrency CFN param.
- README: cost-per-pass estimate for both scripts.
- Replace `sed -n '2,30p' "$0"` help with usage() heredoc in both
  scripts — fragile to header reflows and didn't survive the comment
  expansion this commit adds anyway.
- eval.sh RMS-level parser: add a third fallback (`RMS level:` with no
  `dB` suffix) for older ffmpeg builds where astats predates the unit
  tag. Word-boundary guards keep `RMS peak level` from being eaten.
Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approved — same content as #880, clean rebase onto post-#907 main. All prior findings (subshell pipe, EXIT trap, amix normalize) still fixed. CI green.

Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approve on the recreated #908 (formerly #880, auto-closed when #907's base branch was deleted).

Content matches the prior approved state — same 3 commits (10166b1 script add, 12fdc07 review-feedback fix, a834b30 docs scrub), rebased onto post-#907 main, 3 files / +927/-0.

All 7 prior #880 findings remain addressed:

  • Blocker #1 (subshell-pipe FAILED mutation in eval.sh) → fixed via process-substitution
  • Blocker #2 (no trap on EXIT/ERR) → fixed; both scripts install trap 'cleanup_and_exit $?' EXIT with recursion guard
  • Imp #1 (amix normalize bias) → normalize=0 with explanatory comment
  • Imp #2 (wall-clock methodology bias) → documented in header + README
  • Imp #3 (single-sample stats) → --iterations N flag + median computation
  • Imp #4 (README threshold mismatch) → both scripts + README agree on 40 dB
  • Imp #5 (cost surface undocumented) → README cost-per-pass + --reserved-concurrency flag

Required CI green; regression-shards still in progress but those aren't gating.

Re-review by Vai

@jrusso1020 jrusso1020 merged commit aa58ebc into main May 16, 2026
33 checks passed
@jrusso1020 jrusso1020 deleted the 06-3-feat_lambda_real_aws_smoke_workflow branch May 16, 2026 22:41
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.

3 participants