From ae1f0b96e3a5e18c3fcc8bfef74fa09b15b42213 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:31:28 +0200 Subject: [PATCH] hacky way to configure parallelism --- README.md | 3 ++- src/build.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f2af977..743ce38 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,13 @@ A webapp that checks which Rust targets build at any nightly. It does this by executing `cargo build --release -Zbuild-std=core` for every target and every nightly and displaying the result. There's a background job that continously builds every target for every target that it hasn't built yet. -It does this in parallel, using half of the available threads. +It does this in parallel, using half of the available threads (or `DOES_IT_BUILD_PARALLEL_JOBS`). ## Configuration - `DB_PATH`: Path to SQlite DB to store the results +- `DOES_IT_BUILD_PARALLEL_JOBS`: Parallel build jobs, defaults to cores/2. ## Deployment diff --git a/src/build.rs b/src/build.rs index b4fd52a..c76d7bc 100644 --- a/src/build.rs +++ b/src/build.rs @@ -172,10 +172,14 @@ pub async fn build_every_target_for_toolchain( .await .wrap_err("failed to get targets")?; - let concurrent = std::thread::available_parallelism() - .unwrap_or(NonZeroUsize::new(2).unwrap()) - .get() - / 2; + let concurrent = std::env::var("DOES_IT_BUILD_PARALLEL_JOBS") + .map(|jobs| jobs.parse().unwrap()) + .unwrap_or_else(|_| { + std::thread::available_parallelism() + .unwrap_or(NonZeroUsize::new(2).unwrap()) + .get() + / 2 + }); let results = futures::stream::iter( targets