Repository navigation
Bounded memory for long inputs: streaming front end (1.1.0) - #14
Merged
Merged
Conversation
danigb
force-pushed
the
feat/bounded-memory
branch
from
October 2, 2026 16:41
9a1043f to
b83f457
Compare
Resolve the audio.rs conflict by keeping #13's `decode` submodule and 1.1.0's early `drop(samples)` in `load_audio`. Gate the 1.1.0-only tests (identity_v1_0_0, stream_integration) and the crate-level doc example on `decode`, add a `--no-default-features` clippy/test step to CI, note the new features in the CHANGELOG and date the 1.1.0 entry.
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.
Why
BeatThis::analyze_audioheld the whole signal several times over before the (already chunked) beat model ran, so peak memory grew by about 5.3 GiB per hour of audio. This PR makes the front end stream.What changes
Added
BeatThis::streamandBeatStream::{push, finish, finish_timed}: push monof32chunks of any size as they are decoded; the whole signal never has to be in memory.BeatThis::analyze_owned/analyze_owned_timed: take the caller'sVec<f32>and free it before the beat model runs.Changed
analyze_audio,analyze_ownedandanalyze_filerun throughBeatStream.The public API is additive only; no 1.0.0 signature changes.
Memory
Peak memory footprint in MiB, median of three, Apple M4 Pro (macOS), full model, synthetic mono input at 48 kHz:
streamanalyze_audio(this PR)streamgrows linearly by 93.8 MiB per hour of audio.analyze_audiomeasured 5,651.0 MiB at 60 minutes. That baseline cell was noisy on this host.Output compared with 1.0.0
Identity is checked by
tests/identity_v1_0_0.rs, which runs a verbatim copy of the 1.0.0 pipeline live and compares bits.streamvsanalyze_audio: bit-identical at every rate tested and for every push size.The long-input difference comes from 1.0.0, not from this PR. 1.0.0's whole-input resampler call accumulates position error, which grows sharply past 2^27 input frames (46.6 minutes at 48 kHz). Against an analytic 1 kHz tone over 60 minutes (
resampler_accuracy_long), the chunked resampler's per-minute RMS error stays at 3.2e-6 to 3.3e-6, while 1.0.0's grows to 1.14e-2.load_audioto target rates other than 22,050 Hz also differs from 1.0.0 where the source/target ratio is not exact; the CHANGELOG has the numbers.What was and was not tested
cddc70b) only. That pass was a rerun after a QEMU segfault that also occurs with the older binary.streamtests. This PR's CI is their first native x86 run.Cargo.lock; a consumer resolving a newer rten or rubato patch release could lose bit identity.Notes for review
cargo testis heavier than before: the identity binary takes about 85 s wall on 14 cores. Worth checking the CI duration against the 20-minute timeout.#[doc(hidden)] pub mod __probeis unstable test and measurement infrastructure, used byexamples/memory_probe.rsand the identity tests.