[vla, data] perf: pin pyav decoder to single thread - #135
Merged
Conversation
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
Pin the PyAV video decoder to single-threaded decode (
stream.thread_count = 1) in_decode_pyav, leaving all CPU parallelism to--num-workers.PyAV defaults to
thread_count=0("auto"), which sizes libav's thread pool to the host core count. Because the dataloader already provides process-level parallelism, this is a second parallelism knob layered over the same cores, and the two multiply: at 8 ranks x 16 workers on a 128-core host, 128 loader processes each spinning up ~128 decode threads oversubscribes the machine by orders of magnitude. The pool is also built and torn down on everyav.open(), a cost that a handful of decoded frames never amortizes.Thread-level decode is the worse knob for this access pattern in any case. Our workload is many small, independent seek-and-grab decodes; worker processes scale near-linearly across them, while libav slice threading yields ~1.6x at best on a single stream.
Impact
--num-workers 16, throughput dipped once every 16 iterations as the dataloader round-robin came back around to a stalled worker; that periodic dip is gone.