Repository navigation
perf: faster Instant processing and early playback for everyone - #3530
Draft
richiemcilroy wants to merge 5 commits into
Draft
richiemcilroy wants to merge 5 commits into
richiemcilroy wants to merge 5 commits into
Conversation
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.Fixture runs on a
g6.4xlarge(same type and env as the media workers),mainand this branch alternating, recordings prepared with the desktop's 30 s preverification:Medians of 3 alternating runs per fixture. Totals are the media server's own time from job start to the completion webhook.
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 issues were found.Summary
Speeds up Instant recording completion and enables early playback by default.
No actionable issues were found. Checks were based on source inspection; tests were not run.
Intentional trade-offs acknowledged by
richiemcilroy: video packet hashes change tomurmur3for speed, and a copy created during segment preparation may be copied again when it misses the shared listing.Reviews (1) · Last reviewed commit: "feat(web): play stopped Instant recordin..." · Reviewed by Greptile