Encoders use all CPUs but one by default
libvpx's worker threads wait on each other by spinning. With one thread per core, an encode slows down many times over as soon as anything else wants a core: the capture and conversion of the next frame, another layer, the desktop. The bench on a 4-core machine showed single frames at 1080p and 1440p taking 130-290 ms with 4 threads under load, where the same frames took 9-17 ms with 3 threads next to two other layers. The default (`codec::encoder_cpus`) is now all CPUs but one, for single encoders and for the streamer's split across layers; an explicit `EncoderConfig::threads` still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
1 parent
6187cc24de
commit
3e498497d7
3 files changed
+23
-9
No files matched your search
@@ -530,8 +530,10 @@ fn thread_split(layers: &[LayerSpec], cores: u32) -> Vec<u32> {
|
||||
layers.iter().map(|l| ((f64::from(cores) * area(l) / total).round() as u32).max(1)).collect()
|
||||
}
|
||||
|
||||
/// CPUs split between the layers' encoders (all but one, see
|
||||
/// `voelin_media::codec::encoder_cpus`).
|
||||
fn cores() -> u32 {
|
||||
std::thread::available_parallelism().map_or(1, |n| n.get() as u32)
|
||||
voelin_media::codec::encoder_cpus()
|
||||
}
|
||||
|
||||
fn new_encoder(
|
||||
|
||||
Reference in new issue
Block a user