Skip to content

perf(gpui): cut capped recording scans by 80% in large libraries - #2532

Merged
richiemcilroy merged 1 commit into
CapSoftware:mainfrom
AksharP5:perf/bounded-recording-metadata
Oct 14, 2026
Merged

richiemcilroy merged 1 commit into
CapSoftware:mainfrom
AksharP5:perf/bounded-recording-metadata

Conversation

@AksharP5

@AksharP5 AksharP5 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opening GPUI's recording library reads every recording's metadata before keeping just 20 items. Recents does the same work for 9 items. Older recordings therefore add JSON parsing, upload-state reads and thumbnail checks to each capped scan.

Sort the directory candidates first, then load valid recording items lazily until the view is filled. Missing/corrupt metadata still gets skipped, and full Settings/recovery scans still exhaust the same iterator. Screenshot scanning is unchanged.

Native GPUI release benchmark on Linux/i5-14400F, with 25/1,000/5,000 synthetic metadata bundles (75% four-segment Studio, 25% Instant). This measures the production recording scan, not UI rendering or image decoding. Both algorithms are compiled in the same binary; the eager reference is the original implementation from 3d19c5c. Three alternating paired runs per condition, 3 warmups and 15 samples per run, warm filesystem cache, no builds running. Values are the median of the three run medians.

Recordings Returned limit Eager ms Bounded ms Reduction
25 9 0.157 0.075 52.5%
25 20 0.158 0.131 17.2%
1,000 9 6.447 1.147 82.2%
1,000 20 6.646 1.199 82.0%
5,000 9 35.290 6.759 80.8%
5,000 20 35.663 6.337 82.2%
1,000 1,000 6.615 6.553 0.9%
5,000 5,000 36.309 36.361 -0.1%

For 1,000 recordings, a separate untimed libc-open counter verified 1,000 metadata reads per eager scan versus 9 or 20 per capped scan. The benchmark asserts equal returned fields and order against the eager reference. Directory enumeration/stat/sorting still scale with library size; the full-list control remains essentially unchanged.

Validation: 18 library tests pass in both debug and release, including invalid metadata, ordering, mixed screenshot merging, recording statuses, recovery filtering and thumbnail revisions. cargo fmt, scoped cargo check, and the full Linux GPUI binary build pass. Strict Clippy on local Rust 1.99 is blocked by existing code: restoring the exact base reproduced all 17 distinct app/test diagnostics (27 occurrences), with none in either changed file. No lint suppression or unrelated source fixes are included.

To reproduce with an explicit recording-library directory (read-only), run both eager and bounded modes, changing the limit to 9, 20 or the corpus size:

CAP_GPUI_LIBRARY_BENCH_DIR=/absolute/path/to/recordings \
CAP_GPUI_LIBRARY_BENCH_MODE=bounded \
CAP_GPUI_LIBRARY_BENCH_LIMIT=9 \
cargo test --manifest-path apps/desktop-gpui/Cargo.toml --release --locked \
  --bin cap-gpui library::tests::recording_scan_benchmark \
  -- --exact --ignored --nocapture --test-threads=1
Synthetic fixture used for the measurements

This creates a new temporary library; its recordings have valid metadata but no video or thumbnails because the scan does not read video payloads.

import json
import tempfile
from pathlib import Path

root = Path(tempfile.mkdtemp(prefix="cap-library-benchmark-"))
for count in (25, 1000, 5000):
    library = root / str(count)
    library.mkdir()
    for index in range(count):
        bundle = library / f"{index:05}.cap"
        bundle.mkdir()
        name = f"Instant {index:05}" if index % 4 == 0 else f"Recording {index:05}"
        meta = {"pretty_name": name, "sharing": None}
        if index % 4 == 0:
            meta.update(fps=60, sample_rate=48000)
        else:
            meta["segments"] = [
                {"display": {"path": f"content/segments/segment-{n}/display.mp4", "fps": 60}}
                for n in range(4)
            ]
        (bundle / "recording-meta.json").write_text(json.dumps(meta))
print(root)

Public overlap check: 243 open PRs, 213 issues and relevant completed library work checked immediately before publication; nearby library PRs change worker cancellation or reveal behavior, not bounded metadata loading.

RetriggerConfidence Score: 5/5

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

Summary

The PR sorts recording folders first, then reads metadata only until capped views are filled.

  • Capped recording views load only the newest items they can show.

Reviews (1) · Last reviewed commit: "perf(gpui): cut capped recording scans b..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@AksharP5 is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

@AksharP5 AksharP5 changed the title perf(gpui): cut capped recording scans by 80%+ perf(gpui): cut capped recording scans by 80% in large libraries Oct 14, 2026
@richiemcilroy
richiemcilroy merged commit ef3d197 into CapSoftware:main Oct 14, 2026
19 of 21 checks passed
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.

2 participants