@@ -343,6 +343,8 @@ struct BackpressureConfig {
343
343
bytes_start : u64 ,
344
344
/// Scale for byte-based quadratic backpressure
345
345
bytes_scale : f64 ,
346
+ /// Maximum bytes-based backpressure
347
+ bytes_max_delay : Duration ,
346
348
347
349
/// When should queue-based backpressure start?
348
350
queue_start : f64 ,
@@ -393,8 +395,12 @@ impl Guest {
393
395
bw_tokens : 0 ,
394
396
backpressure_us : backpressure_us. clone ( ) ,
395
397
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
398
404
queue_start : 0.05 ,
399
405
queue_max_delay : Duration :: from_millis ( 5 ) ,
400
406
} ,
@@ -918,10 +924,13 @@ impl GuestIoHandle {
918
924
// the upstairs and downstairs) is particularly high. If so,
919
925
// apply some backpressure by delaying host operations, with a
920
926
// 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
+ ) ;
925
934
926
935
// Compute an alternate delay based on queue length
927
936
let d2 = self
0 commit comments