tokio-rs / loom

Concurrency permutation testing tool for Rust.
MIT License
2.09k stars 110 forks source link

Raising the MAX_THREADS limit? #157

Open rw opened 4 years ago

rw commented 4 years ago

Would it be feasible to raise the MAX_THREADS limit? Perhaps it can by a typenum provided as a type parameter of the runtime, or a crate-level config variable? I need more threads so that I can do the "choice" operator as described in https://github.com/tokio-rs/loom/issues/84#issuecomment-657879201

Thanks!

parasyte commented 3 years ago

I had the same need, and ended up just patching a vendored copy of loom in the meantime:

diff -adupwr /Users/parasyte/other-projects/loom/src/model.rs loom/src/model.rs
--- /Users/parasyte/other-projects/loom/src/model.rs    2020-09-21 02:58:40.000000000 -0700
+++ loom/src/model.rs   2020-09-21 02:06:02.000000000 -0700
@@ -5,7 +5,7 @@ use std::path::PathBuf;
 use std::sync::Arc;
 use std::time::{Duration, Instant};

-const DEFAULT_MAX_THREADS: usize = 4;
+const DEFAULT_MAX_THREADS: usize = 8;
 const DEFAULT_MAX_BRANCHES: usize = 1_000;

 /// Configure a model
diff -adupwr /Users/parasyte/other-projects/loom/src/rt/mod.rs loom/src/rt/mod.rs
--- /Users/parasyte/other-projects/loom/src/rt/mod.rs   2020-10-21 23:40:59.000000000 -0700
+++ loom/src/rt/mod.rs  2020-09-21 02:06:02.000000000 -0700
@@ -57,7 +57,7 @@ mod vv;
 pub(crate) use self::vv::VersionVec;

 /// Maximum number of threads that can be included in a model.
-pub(crate) const MAX_THREADS: usize = 4;
+pub(crate) const MAX_THREADS: usize = 8;

 /// Maximum number of atomic store history to track per-cell.
 pub(crate) const MAX_ATOMIC_HISTORY: usize = 7;