summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-11 16:17:29 -0400
committerAndrew Gallant <jamslam@gmail.com>2023-11-20 23:51:53 -0500
commit53679e4c43e472b2f51d9568455caa10ad399fc4 (patch)
treee8159e76ec9df66e38371ab6e785a87135d654e1
parent8b766a2522f419ac33552b2f82ec2ad79646c601 (diff)
ignore: simplify the work-stealing strategy
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
-rw-r--r--crates/ignore/src/walk.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ignore/src/walk.rs b/crates/ignore/src/walk.rs
index 2d754da1..4fee1d88 100644
--- a/crates/ignore/src/walk.rs
+++ b/crates/ignore/src/walk.rs
@@ -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())
}