Skip to content

Commit

Permalink
Add in progress job count to the scheduler status fixes crossbeam-rs#508
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanchester committed Sep 9, 2019
1 parent 98c6a3f commit 7c0e463
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/bin/sccache-dist/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,12 @@ impl SchedulerIncoming for Scheduler {

fn handle_status(&self) -> Result<SchedulerStatusResult> {
let servers = self.servers.lock().unwrap();
let jobs = self.jobs.lock().unwrap();

Ok(SchedulerStatusResult {
num_servers: servers.len(),
num_cpus: servers.values().map(|v| v.num_cpus).sum(),
in_progress: jobs.len(),
})
}
}
Expand Down
1 change: 1 addition & 0 deletions src/dist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ pub struct JobComplete {
pub struct SchedulerStatusResult {
pub num_servers: usize,
pub num_cpus: usize,
pub in_progress: usize,
}

// SubmitToolchain
Expand Down
4 changes: 2 additions & 2 deletions tests/harness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl DistSystem {
wait_for_http(scheduler_url, Duration::from_millis(100), MAX_STARTUP_WAIT);
wait_for(|| {
let status = self.scheduler_status();
if matches!(self.scheduler_status(), SchedulerStatusResult { num_servers: 0, num_cpus: _ }) { Ok(()) } else { Err(format!("{:?}", status)) }
if matches!(self.scheduler_status(), SchedulerStatusResult { num_servers: 0, num_cpus: _, in_progress: 0 }) { Ok(()) } else { Err(format!("{:?}", status)) }
}, Duration::from_millis(100), MAX_STARTUP_WAIT);
}

Expand Down Expand Up @@ -386,7 +386,7 @@ impl DistSystem {
wait_for_http(url, Duration::from_millis(100), MAX_STARTUP_WAIT);
wait_for(|| {
let status = self.scheduler_status();
if matches!(self.scheduler_status(), SchedulerStatusResult { num_servers: 1, num_cpus: _ }) { Ok(()) } else { Err(format!("{:?}", status)) }
if matches!(self.scheduler_status(), SchedulerStatusResult { num_servers: 1, num_cpus: _, in_progress: 0 }) { Ok(()) } else { Err(format!("{:?}", status)) }
}, Duration::from_millis(100), MAX_STARTUP_WAIT);
}

Expand Down

0 comments on commit 7c0e463

Please sign in to comment.