refactor(irtt-client): move cadence into managed runner
This commit is contained in:
31 files changed
+716
-4106
No files matched your search
@@ -58,11 +58,11 @@ fn synthetic_probe_stream(count: u32) -> Vec<ClientEvent> {
|
||||
events.push(ClientEvent::EchoSent {
|
||||
seq,
|
||||
remote,
|
||||
scheduled_at: sent_at.mono,
|
||||
scheduled_at: Some(sent_at.mono),
|
||||
sent_at,
|
||||
bytes: 64,
|
||||
send_call: Duration::from_micros(50),
|
||||
timer_error: Duration::from_micros(20),
|
||||
timer_error: Some(Duration::from_micros(20)),
|
||||
});
|
||||
|
||||
if seq == count - 1 {
|
||||
|
||||
@@ -100,12 +100,14 @@ impl CoreStats {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_sent(&mut self, bytes: usize, send_call_ns: i128, timer_error_ns: i128) {
|
||||
fn apply_sent(&mut self, bytes: usize, send_call_ns: i128, timer_error_ns: Option<i128>) {
|
||||
self.events.sent_events += 1;
|
||||
self.packets.packets_sent += 1;
|
||||
self.packets.bytes_sent = self.packets.bytes_sent.saturating_add(bytes as u64);
|
||||
self.send_call.push_ns(send_call_ns);
|
||||
self.timer_error.push_ns(timer_error_ns);
|
||||
if let Some(error) = timer_error_ns {
|
||||
self.timer_error.push_ns(error);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_unique_reply(&mut self, is_late: bool, sample: ReplySample) -> EventStatsUpdate {
|
||||
|
||||
@@ -89,11 +89,11 @@ impl StatsConfig {
|
||||
/// # ClientEvent::EchoSent {
|
||||
/// # seq,
|
||||
/// # remote: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 2112),
|
||||
/// # scheduled_at: sent_at.mono,
|
||||
/// # scheduled_at: Some(sent_at.mono),
|
||||
/// # sent_at,
|
||||
/// # bytes: 64,
|
||||
/// # send_call: Duration::from_micros(send_call_us),
|
||||
/// # timer_error: Duration::from_micros(2),
|
||||
/// # timer_error: Some(Duration::from_micros(2)),
|
||||
/// # }
|
||||
/// # }
|
||||
/// #
|
||||
@@ -142,11 +142,11 @@ impl StatsConfig {
|
||||
/// # ClientEvent::EchoSent {
|
||||
/// # seq,
|
||||
/// # remote: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 2112),
|
||||
/// # scheduled_at: sent_at.mono,
|
||||
/// # scheduled_at: Some(sent_at.mono),
|
||||
/// # sent_at,
|
||||
/// # bytes: 64,
|
||||
/// # send_call: Duration::from_micros(send_call_us),
|
||||
/// # timer_error: Duration::from_micros(2),
|
||||
/// # timer_error: Some(Duration::from_micros(2)),
|
||||
/// # }
|
||||
/// # }
|
||||
/// #
|
||||
@@ -418,11 +418,11 @@ impl StatsCollector {
|
||||
/// # ClientEvent::EchoSent {
|
||||
/// # seq,
|
||||
/// # remote: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 2112),
|
||||
/// # scheduled_at: sent_at.mono,
|
||||
/// # scheduled_at: Some(sent_at.mono),
|
||||
/// # sent_at,
|
||||
/// # bytes: 64,
|
||||
/// # send_call: Duration::from_micros(send_call_us),
|
||||
/// # timer_error: Duration::from_micros(2),
|
||||
/// # timer_error: Some(Duration::from_micros(2)),
|
||||
/// # }
|
||||
/// # }
|
||||
/// #
|
||||
@@ -475,11 +475,11 @@ impl StatsCollector {
|
||||
/// # ClientEvent::EchoSent {
|
||||
/// # seq,
|
||||
/// # remote: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 2112),
|
||||
/// # scheduled_at: sent_at.mono,
|
||||
/// # scheduled_at: Some(sent_at.mono),
|
||||
/// # sent_at,
|
||||
/// # bytes: 64,
|
||||
/// # send_call: Duration::from_micros(send_call_us),
|
||||
/// # timer_error: Duration::from_micros(2),
|
||||
/// # timer_error: Some(Duration::from_micros(2)),
|
||||
/// # }
|
||||
/// # }
|
||||
/// #
|
||||
|
||||
@@ -13,7 +13,7 @@ pub(crate) enum StatsEvent {
|
||||
at: Instant,
|
||||
bytes: usize,
|
||||
send_call_ns: i128,
|
||||
timer_error_ns: i128,
|
||||
timer_error_ns: Option<i128>,
|
||||
},
|
||||
UniqueReply {
|
||||
at: Instant,
|
||||
@@ -48,7 +48,7 @@ pub(crate) fn normalize_event(event: &ClientEvent) -> Option<StatsEvent> {
|
||||
at: sent_at.mono,
|
||||
bytes: *bytes,
|
||||
send_call_ns: duration_ns_i128(*send_call),
|
||||
timer_error_ns: duration_ns_i128(*timer_error),
|
||||
timer_error_ns: timer_error.map(duration_ns_i128),
|
||||
}),
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
|
||||
@@ -146,11 +146,11 @@ mod tests {
|
||||
ClientEvent::EchoSent {
|
||||
seq,
|
||||
remote: "127.0.0.1:2112".parse().unwrap(),
|
||||
scheduled_at: sent_at.mono,
|
||||
scheduled_at: Some(sent_at.mono),
|
||||
sent_at,
|
||||
bytes: 32,
|
||||
send_call: Duration::from_micros(10 + u64::from(seq)),
|
||||
timer_error: Duration::from_micros(2 + u64::from(seq)),
|
||||
timer_error: Some(Duration::from_micros(2 + u64::from(seq))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ pub fn sent(seq: u32, sent_at: ClientTimestamp) -> ClientEvent {
|
||||
ClientEvent::EchoSent {
|
||||
seq,
|
||||
remote: "127.0.0.1:2112".parse().unwrap(),
|
||||
scheduled_at: sent_at.mono,
|
||||
scheduled_at: Some(sent_at.mono),
|
||||
sent_at,
|
||||
bytes: 32,
|
||||
send_call: Duration::from_micros(10),
|
||||
timer_error: Duration::from_micros(2),
|
||||
timer_error: Some(Duration::from_micros(2)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ pub fn sent_with_timings(
|
||||
unreachable!();
|
||||
};
|
||||
*send_call = Duration::from_micros(send_call_us);
|
||||
*timer_error = Duration::from_micros(timer_error_us);
|
||||
*timer_error = Some(Duration::from_micros(timer_error_us));
|
||||
event
|
||||
}
|
||||
|
||||
|
||||
@@ -129,11 +129,11 @@ fn build_event(op: &Op, seq: u32, clock_ms: u64, base: Instant) -> ClientEvent {
|
||||
Op::Send => ClientEvent::EchoSent {
|
||||
seq,
|
||||
remote: ADDR.parse().unwrap(),
|
||||
scheduled_at: ts_at(base, clock_ms).mono,
|
||||
scheduled_at: Some(ts_at(base, clock_ms).mono),
|
||||
sent_at: ts_at(base, clock_ms),
|
||||
bytes: 32,
|
||||
send_call: Duration::from_micros(10),
|
||||
timer_error: Duration::from_micros(2),
|
||||
timer_error: Some(Duration::from_micros(2)),
|
||||
},
|
||||
Op::Reply { raw_ms } => {
|
||||
let sent_at = ts_at(base, clock_ms.saturating_sub(u64::from(raw_ms)));
|
||||
|
||||
@@ -13,6 +13,27 @@ use irtt_stats::{
|
||||
EventStatsUpdate, IpdvPairUpdate, LateReplyMode, SampleMode, StatsCollector, StatsConfig,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn caller_paced_sends_do_not_fabricate_timer_error_samples() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
let mut event = sent(0, ts(0));
|
||||
let ClientEvent::EchoSent {
|
||||
scheduled_at,
|
||||
timer_error,
|
||||
..
|
||||
} = &mut event
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
*scheduled_at = None;
|
||||
*timer_error = None;
|
||||
collector.process(&event);
|
||||
let snapshot = collector.snapshot();
|
||||
assert_eq!(snapshot.packets.packets_sent, 1);
|
||||
assert_eq!(snapshot.send_call.count, 1);
|
||||
assert_eq!(snapshot.timer_error.count, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exact_mode_reports_a_timer_error_median() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
|
||||
Reference in new issue
Block a user