Skip to content

perf(desktop-gpui): faster Instant upload tail with far fewer presign requests - #3444

Merged
richiemcilroy merged 4 commits into
mainfrom
perf/instant-upload-tail
Oct 27, 2026
Merged

richiemcilroy merged 4 commits into
mainfrom
perf/instant-upload-tail

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Shortens the Instant upload tail after Stop and removes almost every presign request while recording.

sequenceDiagram
    participant App as Desktop
    participant API as Cap API
    participant S3
    Note over App: before, at Stop
    App->>API: presign thumbnail
    App->>S3: PUT thumbnail
    App->>API: presign manifest
    App->>S3: PUT final manifest
    App->>API: recording-complete
    Note over App: after, at Stop
    par
        App->>API: presign thumbnail (while re-encoding it)
        App->>S3: PUT thumbnail
    and
        App->>S3: PUT final manifest (reused URL)
    end
    App->>API: recording-complete
Loading
  • Manifest URL reuse (apps/desktop-gpui/src/upload.rs): the first batch presign already returns a URL for segments/manifest.json, which was never used. Progress and final manifests now PUT to it instead of calling /api/upload/signed before every PUT (about one presign every two seconds).
    • Kept for at most 10 minutes. The server signs these URLs for 30 minutes (createUploadTarget, expiresIn: 1800).
    • Google Drive resumable sessions are single use, so they are never reused (ReusableUploadTarget::new).
    • If the reused URL is rejected with an HTTP error (for example an expired signature), the same call signs a fresh URL. Timeouts and network errors go through the existing manifest retry backoff, so a hung network still costs one request timeout per attempt.
  • Thumbnail alongside the final manifest (InstantUpload::finish_with_screenshot): the final manifest is authorized first, then the thumbnail upload and the segment finish run together. recording-complete still waits for both, and a failed thumbnail still fails the attempt, which the queue retries exactly as before.
  • Thumbnail work: the JPEG re-encode runs on the blocking pool (it used to block a runtime worker) and overlaps its presign request. Studio share thumbnails get the same change.

Stop tail benchmark

upload::queue::stop_tail_bench drives a live Instant recording through the real upload queue against MockCap, with every API call and object PUT answered after a fixed delay on the virtual clock. Times are from Stop. Baseline is main.

API / object latency Final manifest (main → PR) recording-complete (main → PR)
120 ms / 40 ms 0.36 s → 0.12 s 0.48 s → 0.28 s
200 ms / 80 ms 0.64 s → 0.24 s 0.84 s → 0.48 s
400 ms / 150 ms 1.25 s → 0.45 s 1.65 s → 0.95 s
Recording Requests (main → PR) Presign calls (main → PR)
60 s 132 → 101 35 → 4
30 min 3,656 → 2,758 949 → 51
STOP_TAIL_API_MS=200 STOP_TAIL_OBJECT_MS=80 STOP_TAIL_PAIRS=30 \
  cargo test --bin cap-gpui stop_tail -- --ignored --nocapture

The Instant request budgets in upload/verify_tests.rs drop by one presign per manifest, so a return to per-manifest presigning fails them.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Speeds up Instant uploads after Stop.

  • Instant uploads reuse a signed URL for repeated manifest updates.
  • The final manifest can upload while the recording thumbnail is being sent.
  • Thumbnail compression and URL signing now run at the same time.

The latest change sends network errors through the existing retry backoff instead of immediately signing another URL. No new actionable issues were found.

Reviews (3) · Last reviewed commit: "fix(desktop-gpui): back off before re-si..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 27, 2026 2:04am UTC

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy
richiemcilroy marked this pull request as ready for review October 27, 2026 02:54
@richiemcilroy
richiemcilroy merged commit 4baa1fa into main Oct 27, 2026
66 checks passed
@richiemcilroy
richiemcilroy deleted the perf/instant-upload-tail branch October 27, 2026 02:55

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

This branch was successfully deployed

2 active deployments
Preview – cap-web — 1387ea9d Deployed Oct 27, 2026 by vercel[bot]
Preview – cap-status — 1387ea9d Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant