Skip to content

Commit

Permalink
Merge pull request #1121 from cuviper/octillion-threads
Browse files Browse the repository at this point in the history
Let the octillion test use more threads
  • Loading branch information
cuviper authored Jan 27, 2024
2 parents ba8e1a1 + de000bb commit 32a9c7c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/octillion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ fn two_threads<F: Send + FnOnce() -> R, R: Send>(f: F) -> R {
// FIXME: If we don't use at least two threads, then we end up walking
// through the entire iterator sequentially, without the benefit of any
// short-circuiting. We probably don't want testing to wait that long. ;)
let builder = rayon::ThreadPoolBuilder::new().num_threads(2);
let pool = builder.build().unwrap();

pool.install(f)
if rayon::current_num_threads() < 2 {
use std::sync::OnceLock;
static POOL: OnceLock<rayon::ThreadPool> = OnceLock::new();
let pool = POOL.get_or_init(|| {
let builder = rayon::ThreadPoolBuilder::new().num_threads(2);
builder.build().unwrap()
});
pool.install(f)
} else {
f()
}
}

#[test]
Expand Down

0 comments on commit 32a9c7c

Please sign in to comment.