copr: extract reschedule to inject a fail point
@@ -416,9 +416,8 @@ impl<SS: 'static> BatchExecutorsRunner<SS> {
let mut time_slice_start = Instant::now();
loop {
- let time_slice_len = time_slice_start.saturating_elapsed();
// Check whether we should yield from the execution
- if time_slice_len > MAX_TIME_SLICE {
+ if need_reschedule(time_slice_start) {
reschedule().await;
time_slice_start = Instant::now();
}
@@ -640,3 +639,9 @@ fn grow_batch_size(batch_size: &mut usize) {
}
}
}
+
+#[inline]
+fn need_reschedule(time_slice_start: Instant) -> bool {
+ fail_point!("copr_reschedule", |_| true);
+ time_slice_start.saturating_elapsed() > MAX_TIME_SLICE
+}
