refactor(irtt-stats): rename median mode to sample mode
This commit is contained in:
2 files changed
+26
-26
No files matched your search
@@ -16,7 +16,7 @@ const CONTINUOUS_SEQUENCE_LIMIT: usize = 4096;
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct StatsConfig {
|
pub struct StatsConfig {
|
||||||
pub median: MedianMode,
|
pub samples: SampleMode,
|
||||||
pub rolling_count: Option<usize>,
|
pub rolling_count: Option<usize>,
|
||||||
pub rolling_time: Option<Duration>,
|
pub rolling_time: Option<Duration>,
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ pub struct StatsConfig {
|
|||||||
impl StatsConfig {
|
impl StatsConfig {
|
||||||
pub fn finite() -> Self {
|
pub fn finite() -> Self {
|
||||||
Self {
|
Self {
|
||||||
median: MedianMode::ExactFinite,
|
samples: SampleMode::Exact,
|
||||||
rolling_count: None,
|
rolling_count: None,
|
||||||
rolling_time: None,
|
rolling_time: None,
|
||||||
}
|
}
|
||||||
@@ -32,11 +32,11 @@ impl StatsConfig {
|
|||||||
|
|
||||||
/// Configuration for long-running use.
|
/// Configuration for long-running use.
|
||||||
///
|
///
|
||||||
/// This disables finite median retention and bounds sequence-adjacent IPDV
|
/// This disables exact sample retention and bounds sequence-adjacent IPDV
|
||||||
/// tracking. Exact arbitrary-late IPDV completion is finite-mode behavior.
|
/// tracking. Exact arbitrary-late IPDV completion is finite-mode behavior.
|
||||||
pub fn continuous() -> Self {
|
pub fn continuous() -> Self {
|
||||||
Self {
|
Self {
|
||||||
median: MedianMode::Disabled,
|
samples: SampleMode::RunningOnly,
|
||||||
rolling_count: None,
|
rolling_count: None,
|
||||||
rolling_time: None,
|
rolling_time: None,
|
||||||
}
|
}
|
||||||
@@ -50,9 +50,9 @@ impl Default for StatsConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum MedianMode {
|
pub enum SampleMode {
|
||||||
Disabled,
|
RunningOnly,
|
||||||
ExactFinite,
|
Exact,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
@@ -67,7 +67,7 @@ impl StatsCollector {
|
|||||||
pub fn new(config: StatsConfig) -> Self {
|
pub fn new(config: StatsConfig) -> Self {
|
||||||
Self {
|
Self {
|
||||||
config,
|
config,
|
||||||
cumulative: CoreStats::new(config.median),
|
cumulative: CoreStats::new(config.samples),
|
||||||
rolling_count: config.rolling_count.map(|_| VecDeque::new()),
|
rolling_count: config.rolling_count.map(|_| VecDeque::new()),
|
||||||
rolling_time: config.rolling_time.map(|_| VecDeque::new()),
|
rolling_time: config.rolling_time.map(|_| VecDeque::new()),
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ impl TimeStats {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
struct CoreStats {
|
struct CoreStats {
|
||||||
median: MedianMode,
|
sample_mode: SampleMode,
|
||||||
sequence_limit: Option<usize>,
|
sequence_limit: Option<usize>,
|
||||||
events: EventCounts,
|
events: EventCounts,
|
||||||
packets: PacketCounts,
|
packets: PacketCounts,
|
||||||
@@ -251,10 +251,10 @@ struct CoreStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CoreStats {
|
impl CoreStats {
|
||||||
fn new(median: MedianMode) -> Self {
|
fn new(sample_mode: SampleMode) -> Self {
|
||||||
Self {
|
Self {
|
||||||
median,
|
sample_mode,
|
||||||
sequence_limit: if median == MedianMode::ExactFinite {
|
sequence_limit: if sample_mode == SampleMode::Exact {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(CONTINUOUS_SEQUENCE_LIMIT)
|
Some(CONTINUOUS_SEQUENCE_LIMIT)
|
||||||
@@ -263,14 +263,14 @@ impl CoreStats {
|
|||||||
packets: PacketCounts::default(),
|
packets: PacketCounts::default(),
|
||||||
send_call: TimeMetric::new(false),
|
send_call: TimeMetric::new(false),
|
||||||
timer_error: TimeMetric::new(false),
|
timer_error: TimeMetric::new(false),
|
||||||
rtt_primary: TimeMetric::new(median == MedianMode::ExactFinite),
|
rtt_primary: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
rtt_raw: TimeMetric::new(median == MedianMode::ExactFinite),
|
rtt_raw: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
rtt_adjusted: TimeMetric::new(median == MedianMode::ExactFinite),
|
rtt_adjusted: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
ipdv_round_trip: TimeMetric::new(median == MedianMode::ExactFinite),
|
ipdv_round_trip: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
ipdv_send: TimeMetric::new(median == MedianMode::ExactFinite),
|
ipdv_send: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
ipdv_receive: TimeMetric::new(median == MedianMode::ExactFinite),
|
ipdv_receive: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
send_delay: TimeMetric::new(median == MedianMode::ExactFinite),
|
send_delay: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
receive_delay: TimeMetric::new(median == MedianMode::ExactFinite),
|
receive_delay: TimeMetric::new(sample_mode == SampleMode::Exact),
|
||||||
server_processing: TimeMetric::new(false),
|
server_processing: TimeMetric::new(false),
|
||||||
samples: HashMap::new(),
|
samples: HashMap::new(),
|
||||||
sample_order: VecDeque::new(),
|
sample_order: VecDeque::new(),
|
||||||
@@ -696,7 +696,7 @@ impl RunningStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_window(events: &VecDeque<WindowEvent>) -> Snapshot {
|
fn snapshot_window(events: &VecDeque<WindowEvent>) -> Snapshot {
|
||||||
let mut core = CoreStats::new(MedianMode::Disabled);
|
let mut core = CoreStats::new(SampleMode::RunningOnly);
|
||||||
for event in events {
|
for event in events {
|
||||||
core.apply(event.clone());
|
core.apply(event.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ use std::time::{Duration, Instant};
|
|||||||
|
|
||||||
use common::{late_reply, reply, sent, ts};
|
use common::{late_reply, reply, sent, ts};
|
||||||
use irtt_client::{ClientEvent, PacketMeta};
|
use irtt_client::{ClientEvent, PacketMeta};
|
||||||
use irtt_stats::{EventStatsUpdate, IpdvPairUpdate, MedianMode, StatsCollector, StatsConfig};
|
use irtt_stats::{EventStatsUpdate, IpdvPairUpdate, SampleMode, StatsCollector, StatsConfig};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn disabled_median_avoids_finite_retention() {
|
fn running_only_samples_avoid_finite_retention() {
|
||||||
let mut collector = StatsCollector::new(StatsConfig::continuous());
|
let mut collector = StatsCollector::new(StatsConfig::continuous());
|
||||||
collector.process(&reply(0, 10, 9));
|
collector.process(&reply(0, 10, 9));
|
||||||
collector.process(&reply(1, 20, 19));
|
collector.process(&reply(1, 20, 19));
|
||||||
@@ -22,7 +22,7 @@ fn disabled_median_avoids_finite_retention() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn continuous_mode_tracks_samples_without_exact_medians() {
|
fn continuous_mode_tracks_running_samples_without_exact_medians() {
|
||||||
let mut collector = StatsCollector::new(StatsConfig::continuous());
|
let mut collector = StatsCollector::new(StatsConfig::continuous());
|
||||||
for seq in 0..4104 {
|
for seq in 0..4104 {
|
||||||
collector.process(&reply(seq, 10, 10));
|
collector.process(&reply(seq, 10, 10));
|
||||||
@@ -215,7 +215,7 @@ fn server_processing_and_one_way_require_available_samples() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn rolling_count_eviction_recomputes_from_bounded_events() {
|
fn rolling_count_eviction_recomputes_from_bounded_events() {
|
||||||
let mut collector = StatsCollector::new(StatsConfig {
|
let mut collector = StatsCollector::new(StatsConfig {
|
||||||
median: MedianMode::Disabled,
|
samples: SampleMode::RunningOnly,
|
||||||
rolling_count: Some(2),
|
rolling_count: Some(2),
|
||||||
rolling_time: None,
|
rolling_time: None,
|
||||||
});
|
});
|
||||||
@@ -232,7 +232,7 @@ fn rolling_count_eviction_recomputes_from_bounded_events() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn rolling_time_eviction_uses_event_timestamps() {
|
fn rolling_time_eviction_uses_event_timestamps() {
|
||||||
let mut collector = StatsCollector::new(StatsConfig {
|
let mut collector = StatsCollector::new(StatsConfig {
|
||||||
median: MedianMode::Disabled,
|
samples: SampleMode::RunningOnly,
|
||||||
rolling_count: None,
|
rolling_count: None,
|
||||||
rolling_time: Some(Duration::from_millis(15)),
|
rolling_time: Some(Duration::from_millis(15)),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user