mirror of
https://github.com/Noratrieb/does-it-build.git
synced 2026-01-14 10:25:01 +01:00
Support suspending background thread
Useful for locally testing query timings with sqlx debug logging.
This commit is contained in:
parent
6df7155a50
commit
5fb3ca86b2
1 changed files with 19 additions and 10 deletions
29
src/build.rs
29
src/build.rs
|
|
@ -52,6 +52,13 @@ impl Display for Toolchain {
|
|||
}
|
||||
|
||||
pub async fn background_builder(db: Db) -> Result<()> {
|
||||
if concurrent_jobs() == 0 {
|
||||
info!("Suspending background thread since DOES_IT_BUILD_PARALLEL_JOBS=0");
|
||||
loop {
|
||||
tokio::time::sleep(Duration::from_secs(3600)).await;
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
if let Err(err) = background_builder_inner(&db).await {
|
||||
error!("error in background builder: {err}");
|
||||
|
|
@ -192,21 +199,12 @@ pub async fn build_every_target_for_toolchain(
|
|||
.await
|
||||
.wrap_err("failed to get targets")?;
|
||||
|
||||
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
|
||||
.iter()
|
||||
.map(|target| build_single_target(db, nightly, target, mode)),
|
||||
)
|
||||
.buffer_unordered(concurrent)
|
||||
.buffer_unordered(concurrent_jobs())
|
||||
.collect::<Vec<Result<()>>>()
|
||||
.await;
|
||||
for result in results {
|
||||
|
|
@ -354,3 +352,14 @@ async fn build_target(
|
|||
rustflags,
|
||||
})
|
||||
}
|
||||
|
||||
fn concurrent_jobs() -> usize {
|
||||
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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue