Skip to content

Commit

Permalink
recovery: move RTT related stats and op to a separate struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedo authored May 3, 2024
1 parent ecee257 commit bda3fd2
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 116 deletions.
2 changes: 1 addition & 1 deletion quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6679,7 +6679,7 @@ impl Connection {

let active_path = self.paths.get_active_mut()?;

active_path.recovery.max_ack_delay = max_ack_delay;
active_path.recovery.update_max_ack_delay(max_ack_delay);

if active_path.pmtud.get_probe_status() {
active_path.recovery.pmtud_update_max_datagram_size(
Expand Down
1 change: 1 addition & 0 deletions quiche/src/recovery/bbr/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn bbr_init_pacing_rate(r: &mut Recovery) {
let bbr = &mut r.bbr_state;

let srtt = r
.rtt_stats
.smoothed_rtt
.unwrap_or_else(|| Duration::from_millis(1))
.as_secs_f64();
Expand Down
1 change: 1 addition & 0 deletions quiche/src/recovery/bbr2/pacing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn bbr2_init_pacing_rate(r: &mut Recovery) {
let bbr = &mut r.bbr2_state;

let srtt = r
.rtt_stats
.smoothed_rtt
.unwrap_or_else(|| Duration::from_millis(1))
.as_secs_f64();
Expand Down
2 changes: 1 addition & 1 deletion quiche/src/recovery/bbr2/per_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ fn bbr2_update_min_rtt(r: &mut Recovery, now: Instant) {
// To do: Figure out Probe RTT logic
// if bbr.probe_rtt_min_delay < bbr.min_rtt || bbr.min_rtt == INITIAL_RTT ||
// min_rtt_expired {
if bbr.min_rtt == INITIAL_RTT || min_rtt_expired {
if bbr.min_rtt == rtt::INITIAL_RTT || min_rtt_expired {
// bbr.min_rtt = bbr.probe_rtt_min_delay;
// bbr.min_rtt_stamp = bbr.probe_rtt_min_stamp;
bbr.min_rtt = rs_rtt;
Expand Down
34 changes: 22 additions & 12 deletions quiche/src/recovery/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ fn on_packet_acked(
r.bytes_acked_sl -= r.max_datagram_size;
}

if r.hystart.on_packet_acked(epoch, packet, r.latest_rtt, now) {
if r.hystart
.on_packet_acked(epoch, packet, r.rtt_stats.latest_rtt, now)
{
// Exit to congestion avoidance if CSS ends.
r.ssthresh = r.congestion_window;
}
Expand Down Expand Up @@ -307,7 +309,9 @@ fn on_packet_acked(
let t = now.saturating_duration_since(ca_start_time);

// target = w_cubic(t + rtt)
let target = r.cubic_state.w_cubic(t + r.min_rtt, r.max_datagram_size);
let target = r
.cubic_state
.w_cubic(t + r.rtt_stats.min_rtt, r.max_datagram_size);

// Clipping target to [cwnd, 1.5 x cwnd]
let target = f64::max(target, r.congestion_window as f64);
Expand Down Expand Up @@ -686,7 +690,7 @@ mod tests {
// Shift current time by 1 RTT.
let rtt = Duration::from_millis(100);

r.update_rtt(rtt, Duration::from_millis(0), now);
r.rtt_stats.update_rtt(rtt, Duration::from_millis(0), now);

// Exit from the recovery.
now += rtt;
Expand Down Expand Up @@ -832,7 +836,8 @@ mod tests {
// Receiving Acks.
let now = now + rtt_1st;
for _ in 0..n_rtt_sample {
r.update_rtt(rtt_1st, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_1st, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -871,7 +876,8 @@ mod tests {

for _ in 0..n_rtt_sample {
cwnd_prev = r.cwnd();
r.update_rtt(rtt_2nd, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_2nd, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -913,7 +919,8 @@ mod tests {
// Receiving Acks.
// Last ack will cause to exit to SS.
for _ in 0..n_rtt_sample {
r.update_rtt(rtt_3rd, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_3rd, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -989,7 +996,8 @@ mod tests {
// Receiving Acks.
let now = now + rtt_1st;
for _ in 0..n_rtt_sample {
r.update_rtt(rtt_1st, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_1st, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -1028,7 +1036,8 @@ mod tests {

for _ in 0..n_rtt_sample {
cwnd_prev = r.cwnd();
r.update_rtt(rtt_2nd, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_2nd, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -1068,7 +1077,8 @@ mod tests {

// Receiving Acks.
for _ in 0..n_rtt_sample {
r.update_rtt(rtt_css, Duration::from_millis(0), now);
r.rtt_stats
.update_rtt(rtt_css, Duration::from_millis(0), now);

let mut acked = vec![Acked {
pkt_num: ack_pn,
Expand Down Expand Up @@ -1154,7 +1164,7 @@ mod tests {
}];

// Ack more than cwnd bytes with rtt=100ms
r.update_rtt(rtt, Duration::from_millis(0), now);
r.rtt_stats.update_rtt(rtt, Duration::from_millis(0), now);

// Trigger detecting spurious congestion event
r.on_packets_acked(
Expand Down Expand Up @@ -1217,7 +1227,7 @@ mod tests {
}];

// Ack more than cwnd bytes with rtt=100ms.
r.update_rtt(rtt, Duration::from_millis(0), now);
r.rtt_stats.update_rtt(rtt, Duration::from_millis(0), now);

// Trigger detecting spurious congestion event.
r.on_packets_acked(
Expand Down Expand Up @@ -1277,7 +1287,7 @@ mod tests {

// Shift current time by 1 RTT.
let rtt = Duration::from_millis(100);
r.update_rtt(rtt, Duration::from_millis(0), now);
r.rtt_stats.update_rtt(rtt, Duration::from_millis(0), now);

// Exit from the recovery.
now += rtt;
Expand Down
Loading

0 comments on commit bda3fd2

Please sign in to comment.