Skip to content

perf(project): avoid cloning captions before projection - #2956

Merged
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-caption-projection-allocations
Oct 23, 2026
Merged

richiemcilroy merged 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-caption-projection-allocations

Conversation

@OptimistOtaku

@OptimistOtaku OptimistOtaku commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Caption synchronization clones every source caption and word into a temporary sanitized transcript before projecting any of it. A cut recording pays for thousands of string allocations even when most words are discarded. GPUI runs this path when synchronizing captions after timeline edits and when opening the editor.

Project directly from the borrowed source captions, applying the same f32 word-duration cap when calculating word bounds and overlaps. Only retained output words need their text cloned. Projects without clip mappings still return the same clamped captions. No cache, format, timing, or public API changes.

Measurements

Existing caption-projection-benchmark example, upstream 1965b3179 versus this change. Windows x86_64, Ryzen 5 5600H, Rust 1.88.0 GNU, repository release profile (opt-level=s, thin LTO). Five alternating process runs per version; medians of 25 samples per case, each averaging 50 synchronizations after warmups. All generated-track fingerprints match.

Source / retained clips Before After Speedup
One hour / one full clip 2.947 ms 1.975 ms 1.49×
Ten minutes / 20 four-second clips 0.122 ms 0.033 ms 3.65×
One hour / 60 four-second clips 0.869 ms 0.155 ms 5.61×

These measure complete in-memory synchronize_captions, including projection, override preservation, sorting, and output allocation. They exclude file loading, UI dispatch, and rendering; this is not an overall FPS or editor-startup claim.

Reproduce the API comparison by building both revisions:

cargo build -p cap-project --locked --release --example caption-projection-benchmark
target/release/examples/caption-projection-benchmark 50

The committed ignored benchmark also compares projection directly against the exact old function, including reversed-clip controls:

cargo test -p cap-project --locked --release --lib benchmark_caption_projection_allocations -- --ignored --nocapture

Validation

  • cargo fmt --all
  • cargo check -p cap-project --locked
  • cargo test -p cap-project --locked --lib: 168 passed, three benchmarks ignored by default.
  • cargo clippy -p cap-project --all-targets --locked -- -D warnings
  • git diff --check

Differential tests compare complete projection results, including float bits, against the previous implementation. Cases include capped words, unsorted words, empty and reversed intervals, repeated/reordered/overlapping clips, take offsets, transitions, fullscreen holds, absent mappings, and NaN/infinite timestamps. Existing migration, style-preservation, and serialization tests pass. The native GPUI app was not launched locally.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Caption projection now borrows source captions instead of cloning a temporary clamped copy.

  • Caption projection skips copying words that edited clips discard.

No actionable issues were found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "perf(project): avoid cloning captions be..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 22, 2026 20:47

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@richiemcilroy
richiemcilroy merged commit 4b4aedc into CapSoftware:main Oct 23, 2026
44 of 46 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.

3 participants