Skip to content

perf(project): index edited-time caption migration lookups - #3601

Open
OptimistOtaku wants to merge 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-caption-migration-index
Open

OptimistOtaku wants to merge 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-caption-migration-index

Conversation

@OptimistOtaku

@OptimistOtaku OptimistOtaku commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Opening an older captioned project converts every edited-time caption and word timestamp back to source time. Each timestamp currently scans the clip mappings backwards, so heavily edited recordings pay for a clip scan per word. In the committed complete-synchronization benchmark, a 2,000-clip/20,000-word project drops from 130.42 ms to 30.24 ms (4.31× faster).

For at least 128 clips, validate that edited starts and ends are finite and monotonic, then binary-search the last mapping whose start is at or before the timestamp. Shared boundaries retain the previous reverse scan's last-match priority. Small timelines and invalid/non-monotonic mappings retain the original lookup. Rounded final timestamps and fullscreen-hold conversion are unchanged.

This runs through GPUI caption synchronization and the shared editor-loading path. It only accelerates the legacy source_timed = false conversion; already source-timed captions retain their path. No persistent cache, public API, dependencies, or project-format changes.

Benchmark

Windows x86_64, Ryzen 5 5600H, Rust 1.88 GNU, repository release profile (opt-level=s, thin LTO). Seven alternating paired samples after two warmups; five fresh projects per sample. Inputs are cloned outside timing and complete output projects are compared before measurement. Timings include the full synchronize_captions call: migration, caption projection, sorting and output construction. File I/O, model inference, GPUI launch, and output destruction are excluded.

Clips Words Before After Speedup
1 9,000 8.024 ms 8.293 ms 0.97×
60 1,500 1.447 ms 1.354 ms 1.07×
500 10,000 19.806 ms 9.898 ms 2.00×
2,000 20,000 130.415 ms 30.242 ms 4.31×

The single-clip control was approximately 3% slower. A second complete run measured 1.89× and 4.51× gains at 500 and 2,000 clips, with a roughly 6% slower single-clip control and a neutral 60-clip control. The gain is for older projects with many clip mappings; this is not an overall editor-startup multiplier.

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

Validation

  • cargo fmt --all
  • cargo check --locked -p cap-project
  • cargo test --locked -p cap-project --lib --tests: 204 library tests and four integration tests passed; five benchmarks ignored by default, new benchmark run separately.
  • cargo clippy --locked -p cap-project --all-targets -- -D warnings
  • git diff --check

The reference synchronization function matches upstream f7d351611 exactly. Tests compare whole migrated projects and repeated synchronization, including styles, reordered clips, transitions, overlapping holds, shared/zero-length boundaries, gaps, neighboring float values, non-finite timestamps and invalid timescales. Existing rounded-timeline-end migration tests pass. Native GPUI startup was not exercised locally.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Speeds up legacy caption migration by replacing repeated reverse scans with binary searches on timelines with at least 128 ordered clip mappings.

  • Large, ordered clip lists map legacy caption times faster.

Reviews (1) · Last reviewed commit: "perf(project): retain linear migration f..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 31, 2026 14:20
@vercel

vercel Bot commented Oct 31, 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.

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 insufficient remaining quota. Try requesting a review at a lower effort level.

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.

This branch has not been deployed

No deployments
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