Skip to content

Commit

Permalink
Adative max gso buffer size based on the loss
Browse files Browse the repository at this point in the history
max_burst indicates the maximum size of gso buffer.
It will be reduced by 25% when the outgoing packet loss
rate is increasing, to prevent the further loss caused
by outgoing packet burstness.
  • Loading branch information
junhochoi committed Aug 26, 2022
1 parent 67ee576 commit 4e728bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions apps/src/bin/quiche-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ fn main() {
siduck_conn: None,
app_proto_selected: false,
max_datagram_size,
loss_rate: 0.0,
max_send_burst: MAX_BUF_SIZE,
};

clients.insert(client_id, client);
Expand Down Expand Up @@ -526,9 +528,21 @@ fn main() {
// packets to be sent.
continue_write = false;
for client in clients.values_mut() {
let max_send_burst = client.conn.send_quantum().min(MAX_BUF_SIZE) /
client.max_datagram_size *
client.max_datagram_size;
// Reduce max_send_burst by 25% if loss is increasing more than 0.1%.
let loss_rate =
client.conn.stats().lost as f64 / client.conn.stats().sent as f64;
if loss_rate > client.loss_rate + 0.001 {
client.max_send_burst = client.max_send_burst / 4 * 3;
// Minimun bound of 10xMSS.
client.max_send_burst =
client.max_send_burst.max(client.max_datagram_size * 10);
client.loss_rate = loss_rate;
}

let max_send_burst =
client.conn.send_quantum().min(client.max_send_burst) /
client.max_datagram_size *
client.max_datagram_size;
let mut total_write = 0;
let mut dst_info = None;

Expand Down
4 changes: 4 additions & 0 deletions apps/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct Client {
pub partial_responses: std::collections::HashMap<u64, PartialResponse>,

pub max_datagram_size: usize,

pub loss_rate: f64,

pub max_send_burst: usize,
}

pub type ClientIdMap = HashMap<ConnectionId<'static>, ClientId>;
Expand Down

0 comments on commit 4e728bb

Please sign in to comment.