Skip to content

Commit

Permalink
Tweak flush deadline handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Oct 16, 2024
1 parent 8594113 commit 796a397
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions upstairs/src/upstairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ impl Upstairs {

/// Apply an action returned from [`Upstairs::select`]
pub(crate) fn apply(&mut self, action: UpstairsAction) {
// Check whether the downstairs has live jobs before performing the
// action, because the action may cause it to retire live jobs.
let has_jobs = self.downstairs.has_live_jobs();

match action {
UpstairsAction::Downstairs(d) => {
self.counters.action_downstairs += 1;
Expand Down Expand Up @@ -616,12 +620,6 @@ impl Upstairs {
// because too many jobs have piled up.
self.gone_too_long();

// Only send automatic flushes if the downstairs is fully idle;
// otherwise, keep delaying the flush deadline.
if self.downstairs.has_live_jobs() {
self.flush_deadline = deadline_secs(self.flush_timeout_secs);
}

// Check whether we need to send a Barrier operation to clean out
// complete-but-unflushed jobs.
if self.downstairs.needs_barrier() {
Expand Down Expand Up @@ -682,6 +680,13 @@ impl Upstairs {
// For now, check backpressure after every event. We may want to make
// this more nuanced in the future.
self.set_backpressure();

// We do this last because some of the code above can be slow
// (especially during debug builds), and we don't want to set our flush
// deadline such that it fires immediately.
if has_jobs {
self.flush_deadline = deadline_secs(self.flush_timeout_secs);
}
}

/// Helper function to await all deferred block requests
Expand Down

0 comments on commit 796a397

Please sign in to comment.