From 53c0dcf17acd23af4783b24ecd0639b85e319850 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 1 Oct 2019 18:10:18 -0700 Subject: [PATCH] Don't offset the number of rayon workers by 1 If we pass rayon 0 workers it still spawns 1, so both 1 and 2 threads were actually spawning one thread each. Let's remove the off-by-one so 1 and 2 cores should show a significant difference. --- examples/raytrace-parallel/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/raytrace-parallel/src/lib.rs b/examples/raytrace-parallel/src/lib.rs index fbb9ad68..696c565e 100644 --- a/examples/raytrace-parallel/src/lib.rs +++ b/examples/raytrace-parallel/src/lib.rs @@ -60,7 +60,7 @@ impl Scene { // Configure a rayon thread pool which will pull web workers from // `pool`. let thread_pool = rayon::ThreadPoolBuilder::new() - .num_threads(concurrency - 1) + .num_threads(concurrency) .spawn_handler(|thread| Ok(pool.run(|| thread.run()).unwrap())) .build() .unwrap();