Skip to content

perf(project): index caption mappings across reordered clips - #3602

Open
OptimistOtaku wants to merge 1 commit into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-unordered-caption-projection
Open

OptimistOtaku wants to merge 1 commit into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-unordered-caption-projection

Conversation

@OptimistOtaku

@OptimistOtaku OptimistOtaku commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Moving clips out of source order disables the existing ordered-caption lookup and makes projection scan every clip for every caption. In the committed full-derivation benchmark, a 2,000-clip/6,000-caption shuffled timeline drops from 21.23 ms to 6.90 ms (3.08× faster). This path is used by GPUI caption synchronization after timeline edits and by shared editor loading.

Build a temporary source-sorted mapping index with prefix maximum ends, select overlapping candidates by binary search, then restore their original timeline order before generating caption pieces. That keeps split IDs, output ordering, word timing and source-style inheritance intact. Candidate storage is reused across captions. Already ordered timelines retain the direct slice iterator; fewer than 32 clips or 16 captions, invalid source ranges, non-finite caption bounds and broad candidate spans retain the existing scan. No persistent cache, public API, dependency 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, ten derivations per sample. Complete mapped output and track output are checked against the exact upstream functions before timing. Measurement includes index preparation, projection, override preservation, sorting, allocation and output destruction; excludes I/O, speech recognition and GPUI dispatch.

Clips Source captions Clip order Before After Speedup
20 150 Ordered 0.0396 ms 0.0397 ms 1.00×
20 150 Reversed 0.0730 ms 0.0657 ms 1.11×
20 150 Shuffled 0.0611 ms 0.0635 ms 0.96×
60 900 Ordered 0.1753 ms 0.2073 ms 0.85×
60 900 Reversed 0.1852 ms 0.1635 ms 1.13×
60 900 Shuffled 0.2286 ms 0.2197 ms 1.04×
500 1,500 Ordered 2.2679 ms 2.3341 ms 0.97×
500 1,500 Reversed 1.8711 ms 0.9882 ms 1.89×
500 1,500 Shuffled 1.5264 ms 0.9320 ms 1.64×
2,000 6,000 Ordered 7.7958 ms 7.1419 ms 1.09×
2,000 6,000 Reversed 22.2237 ms 7.6476 ms 2.91×
2,000 6,000 Shuffled 21.2325 ms 6.9007 ms 3.08×

The benefit is concentrated in large reordered timelines. The 60-clip ordered control was about 18% slower in this run; on a second complete run it was neutral, with the other ordered controls 0–4% slower. That rerun retained 1.67–1.69× gains at 500 reordered clips and 3.00–3.08× at 2,000. Absolute timings varied on this workstation. This is a caption derivation benchmark, not an overall editor-FPS multiplier.

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

Validation

  • cargo fmt --all
  • cargo check --locked -p cap-project
  • cargo test --locked -p cap-project --lib --tests: 203 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

Tests compare complete output and float bits across threshold sizes, reversed/shuffled/repeated clips, nested intervals and a long clip overlapping many short clips, shared edges, wordless captions, unsorted/capped/non-finite words, invalid clip ranges, take offsets, speed changes, transitions, overlapping fullscreen holds, split IDs and caption styles. Both baseline functions match upstream f7d351611 exactly. Native GPUI interaction was not exercised locally.

This branch is based directly on main, independently of #3601; the two branches combine without textual conflicts.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Speeds up caption projection for large, reordered timelines with a temporary source-sorted index.

  • Caption projection finds reordered clip overlaps with a temporary index.

Reviewed statically; tests and benchmarks were not run during this review.

Reviews (1) · Last reviewed commit: "perf(project): index caption mappings ac..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 31, 2026 14:36
@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