Skip to content

perf(project): normalize caption words in place - #3436

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

OptimistOtaku wants to merge 1 commit into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-caption-word-normalization

Conversation

@OptimistOtaku

@OptimistOtaku OptimistOtaku commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

GPUI's Whisper and Parakeet caption paths pass owned word vectors to normalize_caption_words, which allocates a second vector and copies every retained word's text. Normalize the existing vector and strings in place, then attach punctuation before applying the existing duration cap.

This retains Unicode trimming, leading/consecutive punctuation, word order, start/end float bits, caption text, and chunk boundaries. Punctuation may still grow the preceding string. No dependencies, public API, project format, or platform-specific code change.

Measurements

Native Windows x86_64, Ryzen 5 5600H, Rust 1.88 GNU, repository release profile (opt-level=s, thin LTO). Median of nine alternating paired samples after warmups. Input batches are cloned before the timer; timings include normalization and dropping the complete output. The benchmark compares the exact upstream function against production code and checks full output equivalence before timing.

Input words Whitespace padding Before After Speedup
32 No 2.233 µs 1.623 µs 1.38×
32 Yes 2.422 µs 1.356 µs 1.79×
1,000 No 94.226 µs 66.918 µs 1.41×
1,000 Yes 86.839 µs 52.445 µs 1.66×
12,000 No 1.151 ms 0.715 ms 1.61×
12,000 Yes 1.021 ms 0.533 ms 1.92×

A second complete run also improved every case. These are normalization timings, excluding speech recognition, model loading, and UI work.

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

Validation

  • cargo fmt --all, cargo check --locked -p cap-project
  • cargo test --locked -p cap-project: 196 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

Differential cases cover Unicode/ASCII whitespace, empty tokens, punctuation chains, multilingual text, signed zero, NaN/infinite times, duration clamping, rendered text, and grouping. A separate test verifies reuse of vector and string allocations. Native GPUI launch is unverified locally. Fork Actions dispatch is disabled by GitHub; upstream PR CI will provide additional platform validation.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Changes normalize_caption_words to reuse the owned vector and strings instead of copying retained words.

  • Caption words are trimmed and joined in place before they become caption segments.

Reviews (1) · Last reviewed commit: "perf(project): normalize caption words i..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 26, 2026 21:30
@vercel

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

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