Skip to content

perf(render-farm): cut peak memory during MP4 header assembly - #2951

Open
AksharP5 wants to merge 1 commit into
CapSoftware:mainfrom
AksharP5:perf/render-farm-mp4-header-memory
Open

AksharP5 wants to merge 1 commit into
CapSoftware:mainfrom
AksharP5:perf/render-farm-mp4-header-memory

Conversation

@AksharP5

@AksharP5 AksharP5 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Finalizing long render-farm exports briefly blocks the coordinator and allocates hundreds of MiB for a small MP4 header. Write each sample-size table into one sized buffer, preserving the existing header bytes and chunk offsets.

Closes #2950.

Export metadata Header time, before → after Peak process RSS, before → after
1 h, 30 fps 232.9 → 20.2 ms 180.8 → 59.1 MiB
2 h, 60 fps 706.1 → 52.2 ms 622.5 → 83.1 MiB
4 h, 60 fps 1408.6 → 108.6 ms 1134.2 → 139.4 MiB

Medians of five alternating fresh-process trials per case with production one-second media runs on Linux, i5-14400F, Bun 1.4.1. The two-hour case cuts header time by 92.6% and peak process RSS by 86.6%. RSS measures transient allocation pressure including the process runtime. The benchmark isolates header assembly; it does not measure total export speed. The linked issue contains the executable benchmark, ranges and baseline commit.

Validation: all 160 render-farm tests pass; sample-size assertions now cover both video and audio tables, asymmetric byte order and unsigned high bits. Scoped Biome and strict TypeScript checks pass. All benchmark headers match byte for byte. A complete four-second MP4 made from real H.264/AAC packets also matches byte for byte and decodes without errors: 240 video frames and 188 AAC frames. No live fleet or S3 deployment was run.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

This PR reduces temporary allocations when building MP4 headers.

  • MP4 exports build sample-size tables with one buffer.

No actionable issues were found. Checks in this review were code-based; tests and benchmarks were not rerun.

Reviews (1) · Last reviewed commit: "perf(render-farm): cut peak memory durin..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 22, 2026 7:54pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 22, 2026 19:54 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — b8afc376 Deployed Oct 22, 2026 by vercel[bot]
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.

MP4 header assembly allocates hundreds of MiB for long render-farm exports

1 participant