Repository navigation
perf(audio): save 330 MiB while preparing 30-minute captions - #2607
Merged
richiemcilroy merged 2 commits intoOct 18, 2026
Merged
Conversation
Contributor
|
@AksharP5 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generating captions for a long Studio recording keeps a full-length scratch mix alongside the final audio while decoded mic/system tracks are still live. Mix into the new output tail and average it in place, preserving prior takes, source offsets, silence, and the existing arithmetic.
This removes one
f32buffer: 329.6 MiB for a 30-minute take at the GPUI caption path’s 48 kHz rate. Fallible reservations still finish before the output length changes.Measured additional live heap inside
append_transcription_audio, excluding input samples and an existing output prefix:The std-only harness includes the actual source module. All 56 paired fixture processes and eight additional checks with GPUI release optimization flags produced matching output-bit digests and confirmed the table’s before/after heap reductions. Each fixture keeps a stereo system source and mono mic source live. Timing is excluded because unrelated host compilation resumed during the run; decoding, normalization, WAV encoding, and speech recognition are outside this measurement.
Validation:
cargo fmt --all,cargo check -p cap-audio,cargo test -p cap-audio --lib transcription_timing(7 tests), andcargo clippy -p cap-audio --all-targets -- -D warningspass with Rust 1.88. The harness also passes 22 bitwise edge cases, invalid-input checks, and injected allocation failures. The two added regression tests cover appending without changing earlier takes and preserving output when validation/reservation fails.Checked the changed files in all 264 public open PRs before publishing; none overlaps this function. Related #2539, #2582, and #1786 affect other stages.
Reproduce the memory and output checks without FFmpeg or a model download
Save the Rust block below as
harness.rsin an empty directory and create itssourcessubdirectory. From this checkout, write the actual baseline and candidate modules there:From that benchmark directory, using Rust 1.88.0:
peak_additional_bytesis the measured live-heap increase.fnv1a64_sample_bits_lecovers every output sample bit. The large cases need about 2 GiB available memory. The initial 56-process run used-C opt-level=3 -C debuginfo=0; the eight profile-confirmation processes used the full flags above and agreed exactly on allocations and output. All runs were retained.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
append_transcription_audionow mixes directly into the output’s new tail, removing one full-lengthf32buffer.Review checks were source-based; no tests or benchmarks were run.
Reviews (1) · Last reviewed commit: "perf(audio): reduce memory while prepari..." · Reviewed by Greptile