Skip to content
Snippets Groups Projects
Commit 9baf1d6c authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato
Browse files

Cap the default number of threads in the pool to 4

The current threads usage is limited to motion estimation and
on machines with a large number of cores the default thread pool
dimension is causing performance degradation.

Fixes #1064
parent cc1d494f
No related branches found
No related tags found
No related merge requests found
......@@ -442,6 +442,8 @@ pub struct Config {
pub threads: usize
}
const MAX_USABLE_THREADS: usize = 4;
impl Config {
pub fn parse(&mut self, key: &str, value: &str) -> Result<(), EncoderStatus> {
match key {
......@@ -468,7 +470,13 @@ impl Config {
None
};
let pool = rayon::ThreadPoolBuilder::new().num_threads(self.threads).build().unwrap();
let threads = if self.threads == 0 {
rayon::current_num_threads().min(MAX_USABLE_THREADS)
} else {
self.threads
};
let pool = rayon::ThreadPoolBuilder::new().num_threads(threads).build().unwrap();
Context {
frame_count: 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment