Repository navigation
perf: faster Instant processing and early playback for everyone - #3530
Merged
Merged
Conversation
Member
Author
|
hey @greptileai, please re-review the PR |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
hey @greptileai, please re-review the PR |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes an Instant recording reach its processed, verified MP4 sooner after Stop, and lets the owner's stopped tab start playing straight away for everyone.
flowchart LR subgraph before[media server, before] direction LR A1[download] --> B1[remux] --> C1["packet proof<br/>(SHA-256 per packet)"] --> D1[chunk decode] --> E1[PUT] --> F1["GET whole object<br/>+ SHA-256"] --> G1[upload previews] end subgraph after[media server, after] direction LR A2[download] --> B2[remux] --> C2["packet proof (murmur3)<br/>‖ chunk decode<br/>‖ SHA-256 + MD5 in own process"] --> E2["PUT ‖ previews"] --> F2["ETag == local MD5?<br/>yes: done · no: GET + SHA-256"] endMedia server (
/video/mux-segments)hashRecordingUpload(apps/media-server/src/lib/recording-verification.ts) computes the SHA-256 plus the ETag S3 returns for the same bytes:"md5"for a single PUT,"md5(part md5s)-N"for multipart at the upload's own part size (apps/media-server/src/lib/upload-digest.ts). When the stored object's ETag (read withIf-Match, size checked) equals it, the whole-object GET + hash is skipped. Any other ETag (SSE-KMS, Drive, other providers) still re-reads every byte exactly as before.bunprocess (same pattern asrecording-audio-timing.ts), so it no longer takes turns with the decoder output the verification parses on the main thread.readTrack(apps/media-server/src/lib/recording-packet-proof.ts) compared source and output packets by FFmpeg's plain-C SHA-256, the slowest read in a long recording's proof. Both sides are hashed by the same ffprobe and only compared with each other, so video packets now usemurmur3(128-bit, ~4x faster). Audio keeps SHA-256 because its tail is checked against a hash computed outside ffprobe.verifyRemuxedRecordingstarts the fragment decode at the same time as the packet proof. The decode only reads the proof for its final count and timing checks; a failed proof still wins (a mismatch is thrown, the decoders are stopped), and a proof error still falls back to the full source inspection.apps/media-server/src/routes/video.ts). The packet proof and the audio decode still wait for the finished output, a failed remux still fails the job as a remux error and stops the decoders before cleanup, and the decoder stall timer ignores the wait for the output. The output probe runs during verification.Fixture runs on a
g6.4xlarge(same type and env as the media workers),mainand this branch alternating, medians of 3. Totals are the media server's own time from job start to the completion webhook.Recordings prepared with the desktop's 30 s preverification:
Recordings with nothing preverified (clients that do not prepare, Drive and custom buckets):
Web
apps/web/lib/desktop-recording-source.ts). Plan, enumerate and copy share one bucket listing; nothing in those phases writes a copy before the copy phase does, and the only other writer (segment preparation) at worst leaves a copy unlisted and it is copied again. Verification still lists afresh, since it is what proves the originals did not change. Four listing rounds per commit become two.dispatchDesktopRecordingJob(apps/web/workflows/finalize-desktop-recording.ts).apps/web/lib/early-instant-playback.ts). The stopped owner tab plays the uploaded prefix while the tail uploads instead of waiting for the whole upload.CAP_EARLY_INSTANT_PLAYBACK=disabledturns it off; any other value (including the current owner list) now means on.Source commit against real S3 from
us-east-1,mainand this branch alternating, 16 rounds each:Rollout
CAP_EARLY_INSTANT_PLAYBACKcan be removed from the production env.

Confidence Score: 5/5
The PR appears safe to merge; no actionable new issues were found.Summary
This PR overlaps recording checks and uploads to reduce the wait after Stop.
No actionable new issues were found. The merge bases differ, so the review covered the full PR diff. No previous review threads were supplied, and no runtime tests were run.
Reviews (3) · Last reviewed commit: "Merge branch 'main' into perf/instant-pr..." · Reviewed by Greptile