Skip to main content

codec_thread_allocation

Function codec_thread_allocation 

Source
pub fn codec_thread_allocation(
    request: CodecThreadRequest,
) -> CodecThreadAllocation
Expand description

Divides the export CPU budget across concurrently active codec contexts.

The configured value is an export-wide cap and a context always needs one worker, so requested decoder concurrency is reduced before threads are assigned. Hardware video encoding does not consume this software budget.

The split is weighted toward the output, but only when there is an output to weight it toward. With a software video encoder a software decode session is sized to its own frame area rather than to an even share, and the encoder takes the remainder above a floor, because it is the stage that paces the run: an even split gave two 27 %-utilized decoders 14 of 22 workers and the 98 %-utilized encoder 8. With a hardware video encoder there is nobody to hand the difference to, and taking it from decode is pure loss: measured on the 4K fixture with nvenc, cutting each software decoder from 11 workers to 5 moved decodeWaitMs from 250 ms to 1,340 ms, so decode stops being ahead of the renderer. That configuration keeps the even split.

A hardware session decodes nothing on the CPU, so one worker should be enough, but it keeps the even share: that is the split it has been measured with, and no smaller share has been measured for speed.