Restore some decode throughput lost since April - #1058
Open
JustinTArthur wants to merge 1 commit into
Open
Conversation
Four independent decoder/demodulator performance regressions roughly halved throughput (including downstream in vhs-decode) 1. LoadFFmpeg/LoadLDF rewind buffer (the bigger one) Appending to and trimming the rewind buffer copies the bytes twice each read. 8a42fec raised LoadFFmpeg's window from 2MB to 16MB, which turned ~4MB of memcpy per 61KB read into ~32MB. Demodulator threads starve waiting on the big copy. Fixed with a bytearray and compaction only once the window has grown to twice its target size. 2. scale_field lost @njit(cache=True) Was dropped in 163408c, I'm guessing an artifact of runtime kernel overrides while testing the change. 3. Sinc LUT's inter-phase interpolation doesn't change anything sinc_phase_count is 2**16, so the nearest tabulated phase is already accurate below float32 precision. Interpolating between the phases was costly. 4. Wasteful np.concatenate on block record arrays nb_concatenate was dropped in 980f3a2 and cf2e13e but the replacement had an expensive deep traversal of block structure.
JustinTArthur
force-pushed
the
restore-decode-throughput
branch
from
July 31, 2026 22:31
432d5c5 to
32132b3
Compare
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.
Checklist
Description
Four independent decoder/demodulator performance regressions roughly halved throughput (including downstream in vhs-decode) and this tries to bring a little performance back.
LoadFFmpeg/LoadLDFrewind buffer (biggest one). Appending to and trimming the rewind buffer copies the bytes twice each read. 8a42fec raisedLoadFFmpeg's window from 2MB to 16MB, which turned ~4MB of memcpy per 61KB read into ~32MB. Demodulator threads starve waiting on the big copy.scale_fieldlost@njit(cache=True). Was dropped in 163408c, I'm guessing an artifact of runtime kernel overrides while testing the change.Sinc LUT's inter-phase interpolation doesn't change anything.
sinc_phase_countis 2**16, so the nearest tabulated phase is already accurate below float32 precision. Interpolating between the phases is costly when this math is encountered frequently.Wasteful
np.concatenateon block record arrays.nb_concatenatewas dropped in 980f3a2 and cf2e13e but the replacement had an expensive deep traversal of block structure.Motivation
When vhs-decode 0.4.0 launched with these regressions, users brought up the slow performance in the Domesday86 Discord.
Changes Made
bytearrayand compaction only once the window has grown to twice its target size. The combination of those two is was better than just either one.cache=Trueback. @eshaz: let me know if you'd wanted to make tap counts or something else runtime-alterable.can't unbox heterogeneous list; this should be faster than the numba kernel anyway.Testing
pytest --output-on-failure)