[1/3] Reduce SILK decode allocations#114
Merged
zshang-oai merged 2 commits intoMay 20, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #114 +/- ##
==========================================
- Coverage 82.96% 82.56% -0.41%
==========================================
Files 22 22
Lines 4697 4742 +45
==========================================
+ Hits 3897 3915 +18
- Misses 609 635 +26
- Partials 191 192 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR reduces allocation churn in the SILK decoder hot path by reusing decoder-owned scratch buffers and avoiding unnecessary LBRR discard work when no redundancy is signaled.
Changes:
- Adds reusable scratch storage to
Decoderfor header flags, pulse/excitation buffers, LPC/NLSF work buffers, pitch/LTP data, and stereo-related decode state. - Refactors allocation-heavy helpers to resize and clear decoder-owned buffers instead of allocating fresh slices.
- Short-circuits LBRR discard decoding when no mid/side LBRR flags are present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JoTurk
approved these changes
May 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.
Summary
Reduce avoidable allocation churn in the SILK decoder hot path. This is part of a series PRs to get an 2x performance boost with low hanging fruits.
What changed
previousFrameLPCValuesstorage instead of allocating a fresh slice on each handoffWhy
The SILK decode path was allocating transient slices on nearly every packet. In local stress benchmarks those allocations were a large avoidable part of the Pion/Opus gap.
This PR keeps the decode algorithm unchanged and only removes repeated scratch allocation work.
Validation
go test ./...