Skip to content

Commit bf25e38

Browse files
authored
Start byte-based backpressure earlier (#1179)
Previously, the system stabilized at about 1.8 GiB of in-flight data. With the tuning in this PR, it stabilizes at around 500-600 MiB instead. This means that when we switch from writes to reads, we doesn't need to wait as long!
1 parent 84d8810 commit bf25e38

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

upstairs/src/guest.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ struct BackpressureConfig {
343343
bytes_start: u64,
344344
/// Scale for byte-based quadratic backpressure
345345
bytes_scale: f64,
346+
/// Maximum bytes-based backpressure
347+
bytes_max_delay: Duration,
346348

347349
/// When should queue-based backpressure start?
348350
queue_start: f64,
@@ -393,8 +395,12 @@ impl Guest {
393395
bw_tokens: 0,
394396
backpressure_us: backpressure_us.clone(),
395397
backpressure_config: BackpressureConfig {
396-
bytes_start: 1024u64.pow(3), // Start at 1 GiB
397-
bytes_scale: 9.3e-8, // Delay of 10ms at 2 GiB in-flight
398+
// Byte-based backpressure
399+
bytes_start: 100 * 1024u64.pow(2), // Start at 100 MiB
400+
bytes_scale: 6e-8, // Delay of 15ms at 2 GiB in-flight
401+
bytes_max_delay: Duration::from_millis(15),
402+
403+
// Queue-based backpressure
398404
queue_start: 0.05,
399405
queue_max_delay: Duration::from_millis(5),
400406
},
@@ -918,10 +924,13 @@ impl GuestIoHandle {
918924
// the upstairs and downstairs) is particularly high. If so,
919925
// apply some backpressure by delaying host operations, with a
920926
// quadratically-increasing delay.
921-
let d1 = (bytes.saturating_sub(self.backpressure_config.bytes_start)
922-
as f64
923-
* self.backpressure_config.bytes_scale)
924-
.powf(2.0) as u64;
927+
let d1 = (self.backpressure_config.bytes_max_delay.as_micros() as u64)
928+
.min(
929+
(bytes.saturating_sub(self.backpressure_config.bytes_start)
930+
as f64
931+
* self.backpressure_config.bytes_scale)
932+
.powf(2.0) as u64,
933+
);
925934

926935
// Compute an alternate delay based on queue length
927936
let d2 = self

0 commit comments

Comments
 (0)