Skip to content

Commit

Permalink
ignore: simplify the work-stealing strategy
Browse files Browse the repository at this point in the history
There's no particular reason for this change. I happened to be looking
at the code again and realized that stealing from your left neighbour
or your right neighbour shouldn't make a difference (and indeed perf is
the same in my benchmarks).

Closes #2624
  • Loading branch information
tavianator authored and BurntSushi committed Oct 12, 2023
1 parent c313535 commit cebde14
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/ignore/src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,15 +1439,15 @@ impl Stack {

/// Steal a message from another queue.
fn steal(&self) -> Option<Message> {
// For fairness, try to steal from index - 1, then index - 2, ... 0,
// then wrap around to len - 1, len - 2, ... index + 1.
// For fairness, try to steal from index + 1, index + 2, ... len - 1,
// then wrap around to 0, 1, ... index - 1.
let (left, right) = self.stealers.split_at(self.index);
// Don't steal from ourselves
let right = &right[1..];

left.iter()
.rev()
.chain(right.iter().rev())
right
.iter()
.chain(left.iter())
.map(|s| s.steal_batch_and_pop(&self.deque))
.find_map(|s| s.success())
}
Expand Down

0 comments on commit cebde14

Please sign in to comment.