Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ allow-unwrap-in-tests = true
allow-dbg-in-tests = true
avoid-breaking-exported-api = false # We have one consumer and can afford to break the API.
pass-by-value-size-limit = 32
doc-valid-idents = ["HyStart", ".."]
doc-valid-idents = ["HyStart", "CHokepoint", ".."]
25 changes: 18 additions & 7 deletions neqo-transport/src/cc/classic_cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,19 @@ pub trait WindowAdjustment: Display + Debug {
/// (`ssthresh`) is set on exit and they can influence how fast the exponential congestion window
/// growth rate during slow start is.
pub trait SlowStart: Display + Debug {
/// Enables a trait implementor to track RTT rounds via the next packet numer that is to be sent
/// out.
fn on_packet_sent(&mut self, sent_pn: packet::Number);
/// Enables a trait implementor to ingest info about sent packets.
fn on_packet_sent(&mut self, _sent_pn: packet::Number, _sent_bytes: usize) {}
Comment thread
omansfeld marked this conversation as resolved.

/// Handle packets being acknowledged during slow start. Returns the congestion window in bytes
/// that slow start should be exited with. If slow start isn't exited returns `None`.
fn on_packets_acked(
&mut self,
rtt_est: &RttEstimate,
largest_acked: packet::Number,
new_acked_bytes: usize,
curr_cwnd: usize,
cc_stats: &mut CongestionControlStats,
now: Instant,
) -> Option<usize>;

/// Calculates the congestion window increase in bytes during slow start. The default
Expand All @@ -138,7 +140,8 @@ pub trait SlowStart: Display + Debug {
}

/// Resets slow start state. Is used after persistent congestion so slow start algorithms
/// perform cleanly in non-initial slow starts.
/// perform cleanly in non-initial slow starts. Can also be used by the implementing algorithm
/// for internal state reset when needed.
fn reset(&mut self) {}
}

Expand Down Expand Up @@ -350,8 +353,10 @@ where
if let Some(exit_cwnd) = self.slow_start.on_packets_acked(
rtt_est,
largest_packet_acked.pn(),
new_acked,
self.current.congestion_window,
cc_stats,
now,
) {
qdebug!("Exited slow start by algorithm");
self.current.congestion_window = exit_cwnd;
Expand Down Expand Up @@ -556,7 +561,7 @@ where

// Pass next packet number to send into slow start algorithm during slow start.
if self.current.phase.in_slow_start() {
self.slow_start.on_packet_sent(pkt.pn());
self.slow_start.on_packet_sent(pkt.pn(), pkt.len());
}

if !self.app_limited() {
Expand Down Expand Up @@ -2128,8 +2133,14 @@ mod tests {
let mut cc_stats = CongestionControlStats::default();

// Dirty HyStart state so current_round_min_rtt is non-None.
cc.slow_start
.on_packets_acked(&RttEstimate::new(RTT), 0, cc.cwnd(), &mut cc_stats);
cc.slow_start.on_packets_acked(
&RttEstimate::new(RTT),
0,
0,
cc.cwnd(),
&mut cc_stats,
now(),
);
assert!(cc.slow_start.current_round_min_rtt().is_some());

cc.detect_persistent_congestion(
Expand Down
9 changes: 6 additions & 3 deletions neqo-transport/src/cc/classic_slow_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::fmt::{self, Display};
use std::{
fmt::{self, Display},
time::Instant,
};

use crate::{cc::classic_cc::SlowStart, packet, rtt::RttEstimate, stats::CongestionControlStats};

Expand All @@ -25,14 +28,14 @@ impl Display for ClassicSlowStart {
}

impl SlowStart for ClassicSlowStart {
fn on_packet_sent(&mut self, _sent_pn: packet::Number) {}

fn on_packets_acked(
&mut self,
_rtt_est: &RttEstimate,
_largest_acked: packet::Number,
_new_acked_bytes: usize,
_curr_cwnd: usize,
_cc_stats: &mut CongestionControlStats,
_now: Instant,
) -> Option<usize> {
// Classic slow start does not have any heuristic for exiting slow start. Always
// returns `None`.
Expand Down
6 changes: 4 additions & 2 deletions neqo-transport/src/cc/hystart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::{
cmp::{max, min},
fmt::Display,
time::Duration,
time::{Duration, Instant},
};

use neqo_common::{qdebug, qtrace};
Expand Down Expand Up @@ -190,7 +190,7 @@ impl HyStart {
}

impl SlowStart for HyStart {
fn on_packet_sent(&mut self, sent_pn: packet::Number) {
fn on_packet_sent(&mut self, sent_pn: packet::Number, _sent_bytes: usize) {
self.maybe_set_window_end(sent_pn);
}

Expand Down Expand Up @@ -229,8 +229,10 @@ impl SlowStart for HyStart {
&mut self,
rtt_est: &RttEstimate,
largest_acked: packet::Number,
_new_acked_bytes: usize,
curr_cwnd: usize,
cc_stats: &mut CongestionControlStats,
_now: Instant,
) -> Option<usize> {
self.collect_rtt_sample(rtt_est.latest_rtt());

Expand Down
6 changes: 6 additions & 0 deletions neqo-transport/src/cc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ mod classic_slow_start;
mod cubic;
mod hystart;
mod new_reno;
mod search;

pub use classic_cc::{CWND_INITIAL_PKTS, ClassicCongestionController, PERSISTENT_CONG_THRESH};
pub use classic_slow_start::ClassicSlowStart;
pub use cubic::Cubic;
pub use hystart::{HyStart, HyStartCssBaseline};
pub use new_reno::NewReno;
#[cfg(test)]
pub use search::Outcome;
pub use search::Search;

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum CongestionTrigger {
Expand Down Expand Up @@ -113,6 +117,8 @@ pub enum SlowStart {
Classic,
#[strum(serialize = "hystart")]
HyStart,
#[strum(serialize = "search")]
Search,
}

#[cfg(test)]
Expand Down
Loading
Loading