Skip to content

Commit 61c0417

Browse files
committed
nits
1 parent cb4daa2 commit 61c0417

3 files changed

Lines changed: 20 additions & 18 deletions

File tree

neqo-transport/src/cc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use cubic::Cubic;
2828
pub use hystart::{HyStart, HyStartCssBaseline};
2929
pub use new_reno::NewReno;
3030
#[cfg(test)]
31-
pub use search::Result;
31+
pub use search::Outcome;
3232
pub use search::Search;
3333

3434
#[derive(Clone, Copy, PartialEq, Eq, Debug)]

neqo-transport/src/cc/search.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{cc::classic_cc::SlowStart, packet, rtt::RttEstimate, stats::Congesti
1818

1919
/// The outcome of a single SEARCH evaluation.
2020
#[derive(Debug, PartialEq, Eq)]
21-
pub enum Result {
21+
pub enum Outcome {
2222
/// Evaluation ran and slow start should be exited with the provided cwnd.
2323
Exit(usize),
2424
/// Evaluation ran and slow start should be continued.
@@ -273,15 +273,15 @@ impl Search {
273273

274274
/// Re-exports the internal `evaluate` function for use in tests.
275275
#[cfg(test)]
276-
pub fn evaluate_test(&self, rtt: Duration, curr_idx: usize, curr_cwnd: usize) -> Result {
276+
pub fn evaluate_test(&self, rtt: Duration, curr_idx: usize, curr_cwnd: usize) -> Outcome {
277277
self.evaluate(rtt, curr_idx, curr_cwnd)
278278
}
279279

280280
/// Evaluates whether SEARCH should exit slow start.
281281
///
282-
/// Returns [`Result::Exit`] with the current cwnd if the normalized delivery-rate
282+
/// Returns [`Outcome::Exit`] with the current cwnd if the normalized delivery-rate
283283
/// difference exceeds [`Self::THRESH`], or a non-exit variant explaining why not.
284-
fn evaluate(&self, rtt: Duration, curr_idx: usize, curr_cwnd: usize) -> Result {
284+
fn evaluate(&self, rtt: Duration, curr_idx: usize, curr_cwnd: usize) -> Outcome {
285285
// Compute how many bins fit in the last RTT. Integer division implicitly floors that value,
286286
// so `prev_idx` might be too recent by a fraction of a bin. Said fraction is scaled to
287287
// `0..[Self::SCALE]` for interpolation in `compute_sent`.
@@ -290,11 +290,11 @@ impl Search {
290290

291291
if prev_idx <= Self::W {
292292
qdebug!("SEARCH: evaluate: not enough data for SEARCH evaluation (warming up)");
293-
return Result::WarmingUp;
293+
return Outcome::WarmingUp;
294294
}
295295
if curr_idx - prev_idx >= Self::EXTRA_BINS {
296296
qdebug!("SEARCH: evaluate: not enough data for SEARCH evaluation (RTT inflated)");
297-
return Result::RttInflated;
297+
return Outcome::RttInflated;
298298
}
299299

300300
let curr_delv = self.compute_delv(curr_idx - Self::W, curr_idx);
@@ -303,7 +303,7 @@ impl Search {
303303

304304
if prev_sent == 0 {
305305
qdebug!("SEARCH: evaluate: prev_sent is zero, can't evaluate");
306-
return Result::ZeroSent;
306+
return Outcome::ZeroSent;
307307
}
308308

309309
let diff = prev_sent.saturating_sub(curr_delv);
@@ -315,13 +315,13 @@ impl Search {
315315
"SEARCH: evaluate: norm_diff {norm_diff} < THRESH {} --> continue",
316316
Self::THRESH
317317
);
318-
return Result::Continue;
318+
return Outcome::Continue;
319319
}
320320
qdebug!(
321321
"SEARCH: evaluate: norm_diff {norm_diff} >= THRESH {} --> exit",
322322
Self::THRESH
323323
);
324-
Result::Exit(curr_cwnd)
324+
Outcome::Exit(curr_cwnd)
325325
}
326326
}
327327

@@ -365,7 +365,7 @@ impl SlowStart for Search {
365365
//
366366
// <https://datatracker.ietf.org/doc/html/draft-chung-ccwg-search-09#section-3.2-17>
367367
match self.evaluate(rtt, curr_idx, curr_cwnd) {
368-
Result::Exit(cwnd) => Some(cwnd),
368+
Outcome::Exit(cwnd) => Some(cwnd),
369369
_ => None,
370370
}
371371
}

neqo-transport/src/cc/tests/search.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use test_fixture::now;
1212

1313
use crate::{
1414
MIN_INITIAL_PACKET_SIZE,
15-
cc::{CongestionControlStats, Result, Search, classic_cc::SlowStart as _, tests::INITIAL_CWND},
15+
cc::{
16+
CongestionControlStats, Outcome, Search, classic_cc::SlowStart as _, tests::INITIAL_CWND,
17+
},
1618
rtt::RttEstimate,
1719
};
1820

@@ -345,7 +347,7 @@ fn sent_and_acked_byte_computation() {
345347
// `sent_bytes` and `delv_bytes` should be `10 * 1000 = 10_000`.
346348
assert!(
347349
sent_bytes == delv_bytes && delv_bytes == 10_000,
348-
"Should have `sent_bytes == delv_bytes == 10_000 and got `sent_bytes = {sent_bytes}` and `delv_bytes = {delv_bytes}`"
350+
"Should have `sent_bytes == delv_bytes == 10_000` and got `sent_bytes = {sent_bytes}` and `delv_bytes = {delv_bytes}`"
349351
);
350352
}
351353

@@ -450,7 +452,7 @@ fn inflated_rtt_is_guarded() {
450452
let high_rtt = Duration::from_millis(600);
451453
assert_eq!(
452454
search.evaluate_test(high_rtt, curr_idx, INITIAL_CWND),
453-
Result::RttInflated,
455+
Outcome::RttInflated,
454456
);
455457
}
456458

@@ -479,7 +481,7 @@ fn no_sent_bytes() {
479481
let curr_idx = search.curr_idx().unwrap();
480482
assert_eq!(
481483
search.evaluate_test(INITIAL_RTT, curr_idx, INITIAL_CWND),
482-
Result::ZeroSent,
484+
Outcome::ZeroSent,
483485
);
484486
}
485487

@@ -509,7 +511,7 @@ fn warming_up() {
509511
let curr_idx = search.curr_idx().unwrap();
510512
assert_eq!(
511513
search.evaluate_test(INITIAL_RTT, curr_idx, INITIAL_CWND),
512-
Result::WarmingUp,
514+
Outcome::WarmingUp,
513515
);
514516

515517
// One more bin crosses the boundary: prev_idx = 13 - 2 = 11 > W(10).
@@ -528,7 +530,7 @@ fn warming_up() {
528530
// Now the SEARCH checks should run.
529531
assert_eq!(
530532
search.evaluate_test(INITIAL_RTT, curr_idx, INITIAL_CWND),
531-
Result::Continue,
533+
Outcome::Continue,
532534
);
533535
}
534536

@@ -572,7 +574,7 @@ fn continue_when_delivery_rate_steady() {
572574
let curr_idx = search.curr_idx().unwrap();
573575
assert_eq!(
574576
search.evaluate_test(INITIAL_RTT, curr_idx, INITIAL_CWND),
575-
Result::Continue,
577+
Outcome::Continue,
576578
);
577579
}
578580
}

0 commit comments

Comments
 (0)