Skip to content

Commit bb2e4a9

Browse files
committed
Allow configuring thread count.
1 parent a6a1143 commit bb2e4a9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/bin/builder.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ struct Flavor {
9696
target: String,
9797
}
9898

99-
const NUM_THREADS: usize = 4;
100-
10199
fn load_manifest_bytes(crate_path: &Path) -> Vec<u8> {
102100
let manifest_path = crate_path.join("Cargo.toml");
103101
fs::read(&manifest_path).unwrap()
@@ -170,6 +168,14 @@ fn main() -> io::Result<()> {
170168
let mut zup_tree = zup::write::Tree::new();
171169
let mut zup_flavors = Vec::new();
172170

171+
let mut num_threads = 1usize;
172+
if let Ok(v) = env::var("BUILDER_THREADS") {
173+
if let Ok(n) = v.parse() {
174+
num_threads = n;
175+
}
176+
}
177+
println!("using {} threads", num_threads);
178+
173179
let args: Vec<_> = env::args().collect();
174180
let crate_path = PathBuf::from(&args[1]);
175181
let output_path = PathBuf::from(&args[2]);
@@ -197,7 +203,7 @@ fn main() -> io::Result<()> {
197203

198204
thread::scope(|s| {
199205
// Spawn workers
200-
for i in 0..NUM_THREADS {
206+
for i in 0..num_threads {
201207
let j = i;
202208
let rx = &rx;
203209
let crate_path = &crate_path;

0 commit comments

Comments
 (0)