Repository navigation
perf(audio): reduce caption mixing time and contributor-count memory - #2608
richiemcilroy merged 2 commits into
Conversation
|
@dennisimoo is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks @dennisimoo. #2607 just merged and changed the same function, so this now conflicts with main in Both savings can stack: sum into the |
8d73e8c to
7606d1e
Compare
|
@greptile review |
|
Rebased onto main in 7606d1e. The mix still accumulates directly into Validation: 83 cap-audio tests passed, one ignored; cargo check, Clippy with A fresh Greptile review is running. The GitHub Actions workflows are waiting for maintainer approval. |
Caption preparation allocates a
u32contributor count for every 48 kHz frame while decoded mic/system audio and the mix buffer are also live. A source contributes over one continuous interval, so only its start and end can change that count.Replace the recording-sized count buffer with two boundary events per source and average each span in place. Clip the source iterator once instead of checking the destination for every frame. Keep main’s direct accumulation into the appended
outputslice, then divide that slice over the boundary intervals. Source/channel accumulation order, offsets, silence and previous takes stay unchanged.This saves 329.6 MiB per continuous 30-minute take. Rebased onto main after #2607: its removal of the separate
f32mix buffer is preserved, so both memory savings stack.Measurements
Linux x86_64, Xeon Platinum 8175M, Rust 1.88.0, opt-level 3/thin LTO/one codegen unit. These refreshed measurements compile the included example and each revision’s transcription module directly with
rustc, excluding unrelated crate dependencies. Three interleaved fresh processes per version and fixture, pinned to one CPU, with no concurrent builds. Baseline:2b2bf844.Assembly takes 58–59% less time in the long cases. The timer excludes fixture generation and output checksumming; RSS includes decoded inputs. This is audio assembly, not decoding, model inference, or total caption-generation time. All output-bit checksums match.
Validation
cargo +1.88.0 check -p cap-audio --lockedcargo +1.88.0 fmt --all --checkcargo +1.88.0 test -p cap-audio --locked --lib: 83 passed, one ignored.cargo +1.88.0 clippy -p cap-audio --all-targets --locked -- -D warningsinterval_counts_match_per_sample_counts_and_preserve_previous_takesadjacent_overlapping_and_disjoint_source_boundaries_keep_exact_averagesinvalid_append_leaves_existing_samples_unchangedReproduce the benchmark
With the repository's native dependencies configured, build the included example to exercise the same fixture through the crate:
Repeat with
60seconds andmic. For a crate-linked baseline, copy the same example into a worktree at2b2bf844, build with identical settings, and alternate the two binaries in fresh processes. The stereo fixture delays the microphone by 125 ms. On Linux,taskset -c 0can pin each process as in the table.AI-assisted with Codex.


Confidence Score: 5/5
The PR appears safe to merge; no blocking issues were found.Summary
Replaces per-frame contributor counts with two boundary events per source and clips each source before mixing.
Reviews (2) · Last reviewed commit: "perf(audio): replace per-sample transcri..." · Reviewed by Greptile