Repository navigation
Perf: stream LoudnessMeter blocks through a ring buffer (−127 MB analysis spike) - #116
Merged
sanylax0 merged 1 commit intoJul 20, 2026
Conversation
…ysis spike) integratedLUFS allocated a full-length [Double] weighted buffer (~127 MB for a 6-minute track) on top of the mono analysis buffer — a transient spike that ran while music plays and fed the jetsam budget. The weighted samples now stream through a single block-sized ring (~140 KB); each 400 ms block's mean-square is summed from the ring in the same order as before, so results are bit-identical (regression test compares against the old implementation verbatim, including at sample rates where the block isn't a whole multiple of the hop). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP
sanylax0
approved these changes
Jul 20, 2026
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.
Part 1 of the CPU/memory audit (full findings summarized in the audit report; this PR is the largest single memory win).
What
LoudnessMeter.integratedLUFSallocated a full-length[Double]weighted buffer — ~127 MB for a 6-minute track — on top of the ~63 MB mono analysis buffer. That transient spike runs while music plays (post-ready analysis) and feeds directly into the jetsam budget.The K-weighted samples now stream through a single block-sized ring buffer (~140 KB). Each 400 ms block's mean-square is summed from the ring in the same logical order as the old whole-buffer loop, so the output is bit-identical — same filters, same summation order, same gating.
Verification
New
testStreamingMatchesReferenceImplementationembeds the pre-optimization implementation verbatim and asserts exact equality across 44.1 kHz, 48 kHz, and 44 056 Hz (a rate where integer truncation makes the block a non-multiple of the hop — the tail case). Runs incore-tests-linux.No functional or visual change; analysis peak memory drops by ~127 MB per track.
🤖 Generated with Claude Code
https://claude.ai/code/session_013TJoWkqg8bzkGdzxWhWjWP
Generated by Claude Code