Skip to content

Commit 53c0dcf

Browse files
committed
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.
1 parent 6d1dc81 commit 53c0dcf

File tree

1 file changed

+1
-1
lines changed
  • examples/raytrace-parallel/src

1 file changed

+1
-1
lines changed

examples/raytrace-parallel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Scene {
6060
// Configure a rayon thread pool which will pull web workers from
6161
// `pool`.
6262
let thread_pool = rayon::ThreadPoolBuilder::new()
63-
.num_threads(concurrency - 1)
63+
.num_threads(concurrency)
6464
.spawn_handler(|thread| Ok(pool.run(|| thread.run()).unwrap()))
6565
.build()
6666
.unwrap();

0 commit comments

Comments
 (0)