build-manifest: allow configuring the number of threads
This commit is contained in:
parent
24d04ccd39
commit
f3d07b36ed
@ -243,6 +243,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"flate2",
|
||||
"hex 0.4.2",
|
||||
"num_cpus",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -14,3 +14,4 @@ tar = "0.4.29"
|
||||
sha2 = "0.9.1"
|
||||
rayon = "1.3.1"
|
||||
hex = "0.4.2"
|
||||
num_cpus = "1.13.0"
|
||||
|
@ -207,13 +207,18 @@ fn main() {
|
||||
// related code in this tool and ./x.py dist hash-and-sign can be removed.
|
||||
let legacy = env::var("BUILD_MANIFEST_LEGACY").is_ok();
|
||||
|
||||
// Avoid overloading the old server in legacy mode.
|
||||
if legacy {
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(1)
|
||||
.build_global()
|
||||
.expect("failed to initialize Rayon");
|
||||
}
|
||||
let num_threads = if legacy {
|
||||
// Avoid overloading the old server in legacy mode.
|
||||
1
|
||||
} else if let Ok(num) = env::var("BUILD_MANIFEST_NUM_THREADS") {
|
||||
num.parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
|
||||
} else {
|
||||
num_cpus::get()
|
||||
};
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(num_threads)
|
||||
.build_global()
|
||||
.expect("failed to initialize Rayon");
|
||||
|
||||
let mut args = env::args().skip(1);
|
||||
let input = PathBuf::from(args.next().unwrap());
|
||||
|
Loading…
x
Reference in New Issue
Block a user