Skip to content

Commit

Permalink
Fix check_download_progress [scheduler]
Browse files Browse the repository at this point in the history
It was jailing workers unfairly after a new assignment has been applied
  • Loading branch information
kalabukdima committed Dec 23, 2024
1 parent ecadac8 commit 1d00914
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/network-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "network-scheduler"
version = "2.0.0"
version = "2.0.1"
edition = "2021"

[dependencies]
Expand Down
12 changes: 7 additions & 5 deletions crates/network-scheduler/src/worker_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ impl WorkerState {

/// Check if the worker is making progress with downloading missing chunks.
/// Returns true iff the worker is fully synced or making progress.
pub fn check_download_progress(
&mut self,
_units: &DashMap<UnitId, SchedulingUnit>,
) -> bool {
pub fn check_download_progress(&mut self, _units: &DashMap<UnitId, SchedulingUnit>) -> bool {
assert!(!self.jailed);
let Some(last_assignment) = self.last_assignment.as_ref() else {
return true; // worker doesn't have any assignment
Expand Down Expand Up @@ -215,7 +212,12 @@ impl WorkerState {
}
}

pub fn reset_download_progress(&mut self, _units: &DashMap<UnitId, SchedulingUnit>) {
pub fn reset_download_progress(&mut self, units: &DashMap<UnitId, SchedulingUnit>) {
self.num_missing_chunks = self
.assigned_units
.iter()
.map(|unit| units.get(unit).map_or(0, |u| u.num_chunks()))
.sum::<usize>() as u32;
self.last_assignment = Some(SystemTime::now());
}

Expand Down

0 comments on commit 1d00914

Please sign in to comment.