Skip to content

Commit

Permalink
drop everything we cannot forward within 100ms
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Apr 19, 2024
1 parent bd9fbaa commit 225da20
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ impl SchedulerController {
// This doubles as a way to clean the queue as well as forwarding transactions.
const CHUNK_SIZE: usize = 64;
let mut ids_to_add_back = Vec::new();
let mut max_time_reached = false;
while !self.container.is_empty() {
let mut filter_array = [true; CHUNK_SIZE];
let mut ids = Vec::with_capacity(CHUNK_SIZE);
Expand Down Expand Up @@ -297,6 +298,7 @@ impl SchedulerController {
}

if start.elapsed() >= MAX_FORWARDING_DURATION {
max_time_reached = true;
break;
}
}
Expand All @@ -308,6 +310,15 @@ impl SchedulerController {
self.forward_work_sender.send(forward_work).unwrap();
}

// If we hit the time limit. Drop everything that was not checked/processed.
// If we cannot run these simple checks in time, then we cannot run them during
// leader slot.
if max_time_reached {
while let Some(id) = self.container.pop() {
self.container.remove_by_id(&id.id);
}
}

if hold {
for priority_id in ids_to_add_back {
self.container.push_id_into_queue(priority_id);
Expand Down

0 comments on commit 225da20

Please sign in to comment.