Skip to content

Commit

Permalink
Added a max steal limit based on the number of workers
Browse files Browse the repository at this point in the history
  • Loading branch information
pyprogrammer authored and Xudong-Huang committed Sep 1, 2024
1 parent 466ea23 commit 7cf4a4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Scheduler {
pub fn run_queued_tasks(&self, id: usize) {
let local = unsafe { &mut *self.local_queues.get_unchecked(id).get() };

let max_steal: usize = 8;
let max_steal: usize = std::cmp::min(8, self.workers - 1);

#[cfg(feature = "rand_work_steal")]
let mut rng = fastrand::Rng::new();
Expand All @@ -166,7 +166,7 @@ impl Scheduler {
if #[cfg(feature = "rand_work_steal")] {
let target = rng.usize(0..self.workers);
} else {
let target = (id + _i) % self.workers;
let target = (id + _i + 1) % self.workers;
}
};
let stealer = self.stealers.get(target).unwrap();
Expand Down

0 comments on commit 7cf4a4e

Please sign in to comment.