Skip to content

perf: move the mel buffer into the 1-item MelBatch instead of copying it - #67

Open
sylvestre wants to merge 1 commit into
mudler:masterfrom
sylvestre:move-mel-batch
Open

perf: move the mel buffer into the 1-item MelBatch instead of copying it#67
sylvestre wants to merge 1 commit into
mudler:masterfrom
sylvestre:move-mel-batch

Conversation

@sylvestre

@sylvestre sylvestre commented Sep 5, 2026

Copy link
Copy Markdown

encode_16k and transcribe_16k_ctc_logits both assigned feats to mb1.data by copy. That branch is the long-audio path, where feats is n_mels * T floats (tens of MB for minutes of audio), so the copy doubles peak mel-buffer footprint for exactly the inputs where memory is tightest.

feats is dead after the assignment on that branch: it is only read again by the encoder.forward() call in the else branch.

Found by Coverity (COPY_INSTEAD_OF_MOVE) running over the copy of parakeet.cpp vendored in Firefox.
https://bugzilla.mozilla.org/show_bug.cgi?id=2069578

Assisted-by: Claude:claude-opus-5 [Claude Code]

encode_16k and transcribe_16k_ctc_logits both assigned feats to mb1.data by
copy. That branch is the long-audio path, where feats is n_mels * T floats
(tens of MB for minutes of audio), so the copy doubles peak mel-buffer
footprint for exactly the inputs where memory is tightest.

feats is dead after the assignment on that branch: it is only read again by
the encoder.forward() call in the else branch.

Found by Coverity (COPY_INSTEAD_OF_MOVE) running over the copy of
parakeet.cpp vendored in Firefox.

Signed-off-by: Sylvestre Ledru <sylvestre@debian.org>
Assisted-by: Claude:claude-opus-5 [Claude Code]
@localai-org-maint-bot

Copy link
Copy Markdown
Collaborator

@mudler This is good to merge from source review at 07f40c0. In both tiled branches, feats has no later reader; its only other use is in the mutually exclusive untiled branch. Moving it into MelBatch::data preserves the encoder input and removes the duplicate mel allocation. The diff is limited to those two assignments and is mergeable. No CI checks are attached, and I did not run model inference locally.

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.

2 participants