From c4292fb2beb00ab21c74f846b56ecc99ebe12422 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 29 Apr 2020 14:40:54 -0700 Subject: [PATCH] Allow setting the number of filetest threads via the CRANELIFT_FILETESTS_THREADS env var --- cranelift/filetests/src/concurrent.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cranelift/filetests/src/concurrent.rs b/cranelift/filetests/src/concurrent.rs index 30e2c94cfe..67592ed03e 100644 --- a/cranelift/filetests/src/concurrent.rs +++ b/cranelift/filetests/src/concurrent.rs @@ -50,7 +50,16 @@ impl ConcurrentRunner { heartbeat_thread(reply_tx.clone()); - let handles = (0..num_cpus::get()) + let num_threads = std::env::var("CRANELIFT_FILETESTS_THREADS") + .ok() + .map(|s| { + use std::str::FromStr; + let n = usize::from_str(&s).unwrap(); + assert!(n > 0); + n + }) + .unwrap_or_else(|| num_cpus::get()); + let handles = (0..num_threads) .map(|num| worker_thread(num, request_mutex.clone(), reply_tx.clone())) .collect();