Skip to content

perf(gpui): accelerate transcription audio preparation - #3349

Open
vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:perf/transcription-audio-preparation
Open

vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:perf/transcription-audio-preparation

Conversation

@vedanth-jadhav

@vedanth-jadhav vedanth-jadhav commented Oct 26, 2026 •

Copy link
Copy Markdown

Preparing GPUI captions currently scans the full mixed sample buffer in the unoptimized UI crate, then creates/resamples/encodes one FFmpeg frame for every 1,024 PCM input samples. A long recording pays this cost before inference starts.

Move the unchanged, non-generic normalization routine into the existing optimized cap-audio dependency, and use 16,384-sample batches when the PCM encoder reports no required frame size. Decode/mixing order, offsets, gain arithmetic, resampling, inference and error handling remain unchanged. This also uses the optimized normalizer when Whisper reads a standalone WAV.

Measurements

Native audio-preparation reproduction, metadata read through finished WAV, not full caption generation or a timed GPUI executable. Five fresh processes per mode/workload, alternating order; Linux x86_64 AMD EPYC 9V74 host, two-CPU quota/affinity, FFmpeg 7.1.5. Every complete WAV matched baseline bytes in all 75 final comparisons.

Build layout / synthetic workload Before After Reduction
Development-style (caller opt=0, audio/mixer opt=2); 1-hour AAC mic 9.18850s 5.32573s 42.0%
Development-style (caller opt=0, audio/mixer opt=2); 1-hour independent mic + system 11.98499s 8.53021s 28.8%
Development-style (caller opt=0, audio/mixer opt=2); 10-second mic control 0.02868s 0.01814s 36.8%
Shipping-style (caller/audio/mixer opt=3); 1-hour AAC mic 3.71369s 3.47909s 6.3%
Shipping-style (caller/audio/mixer opt=3); 1-hour independent mic + system 5.95156s 5.74254s 3.5%
Shipping-style (caller/audio/mixer opt=3); 10-second mic control 0.01355s 0.01279s 5.6%

The seconds-level normalization gain applies to the documented development optimization boundary. Shipping already optimizes that routine; the smaller shipping gain comes primarily from reducing PCM frame/packet overhead, and shipping run ranges overlap. Rust 1.88.0 native reproduction retains thin LTO, unlike GPUI dev; it reproduces optimization levels rather than the entire UI build. Raw samples, min/max ranges, source-faithful native probe, fixtures recipe and reproduction commands: benchmark evidence.

Verification and risk

  • cargo test --locked -p cap-audio --lib: 104 passed, 3 ignored, including five new normalization cases.
  • Differential WAV test covers 14 lengths: empty, resampler-delay, old/new frame boundaries and partial final frames. Executed with the exact production writer/test source in the native audio example; the same test is included in GPUI.
  • Stable Rust 1.99.1 cross-profile comparison checks legacy opt=0 versus the moved opt=2 normalizer, including signed zero, NaN/Inf, subnormals and varied lengths/amplitudes.
  • Audio cargo check, strict all-targets Clippy, workspace formatting, explicit stable/edition-2024 GPUI formatting and diff checks pass.
  • Full GPUI cargo check --locked -p cap-desktop-gpui --bin cap-gpui now passes, after updating the local dependency with Cap’s current scripts/prepare-gpui-dependency.sh patch stack. The earlier local E0599 was caused by stale dependency patches, not an upstream source defect. Full GPUI tests and ASR inference are not claimed.

The DSP formula and sample order are copied unchanged. Larger bounded PCM batches trade slightly larger temporary frames for fewer allocations/packets; all tested WAV bytes remain identical. No flushing, timeline semantics or inference changes. Checked open transcription work #2747 (timeline selection), #2814 (inference threads), and #3344 (model installation): these address separate behavior and retain the affected helpers.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

This PR speeds up audio preparation before transcription.

  • GPUI transcription uses a shared audio routine to normalize samples.
  • GPUI writes transcription audio in larger PCM batches.
  • Caption imports are reordered without changing behavior.

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

Reviews (1) · Last reviewed commit: "perf(gpui): accelerate transcription aud..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

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.

1 participant