Skip to content

Commit 3d2948d

Browse files
authored
chore: QlogMetric -> qlog::Metric (#3007)
1 parent c821105 commit 3d2948d

4 files changed

Lines changed: 31 additions & 40 deletions

File tree

neqo-transport/src/cc/classic_cc.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ use ::qlog::events::{quic::CongestionStateUpdated, EventData};
1616
use neqo_common::{const_max, const_min, qdebug, qinfo, qlog::Qlog, qtrace};
1717

1818
use super::CongestionControl;
19-
use crate::{
20-
packet,
21-
qlog::{self, QlogMetric},
22-
recovery::sent,
23-
rtt::RttEstimate,
24-
sender::PACING_BURST_SIZE,
25-
Pmtud,
26-
};
19+
use crate::{packet, qlog, recovery::sent, rtt::RttEstimate, sender::PACING_BURST_SIZE, Pmtud};
2720

2821
pub const CWND_INITIAL_PKTS: usize = 10;
2922
const PERSISTENT_CONG_THRESH: u32 = 3;
@@ -210,7 +203,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
210203

211204
if self.state.in_recovery() {
212205
self.set_state(State::CongestionAvoidance, now);
213-
qlog::metrics_updated(&self.qlog, &[QlogMetric::InRecovery(false)], now);
206+
qlog::metrics_updated(&self.qlog, &[qlog::Metric::InRecovery(false)], now);
214207
}
215208

216209
new_acked += pkt.len();
@@ -266,8 +259,8 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
266259
qlog::metrics_updated(
267260
&self.qlog,
268261
&[
269-
QlogMetric::CongestionWindow(self.congestion_window),
270-
QlogMetric::BytesInFlight(self.bytes_in_flight),
262+
qlog::Metric::CongestionWindow(self.congestion_window),
263+
qlog::Metric::BytesInFlight(self.bytes_in_flight),
271264
],
272265
now,
273266
);
@@ -299,7 +292,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
299292
}
300293
qlog::metrics_updated(
301294
&self.qlog,
302-
&[QlogMetric::BytesInFlight(self.bytes_in_flight)],
295+
&[qlog::Metric::BytesInFlight(self.bytes_in_flight)],
303296
now,
304297
);
305298

@@ -346,7 +339,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
346339
self.bytes_in_flight -= pkt.len();
347340
qlog::metrics_updated(
348341
&self.qlog,
349-
&[QlogMetric::BytesInFlight(self.bytes_in_flight)],
342+
&[qlog::Metric::BytesInFlight(self.bytes_in_flight)],
350343
now,
351344
);
352345
qtrace!("[{self}] Ignore pkt with size {}", pkt.len());
@@ -357,7 +350,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
357350
self.bytes_in_flight = 0;
358351
qlog::metrics_updated(
359352
&self.qlog,
360-
&[QlogMetric::BytesInFlight(self.bytes_in_flight)],
353+
&[qlog::Metric::BytesInFlight(self.bytes_in_flight)],
361354
now,
362355
);
363356
}
@@ -388,7 +381,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
388381
);
389382
qlog::metrics_updated(
390383
&self.qlog,
391-
&[QlogMetric::BytesInFlight(self.bytes_in_flight)],
384+
&[qlog::Metric::BytesInFlight(self.bytes_in_flight)],
392385
now,
393386
);
394387
}
@@ -520,7 +513,7 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> {
520513
self.set_state(State::PersistentCongestion, now);
521514
qlog::metrics_updated(
522515
&self.qlog,
523-
&[QlogMetric::CongestionWindow(self.congestion_window)],
516+
&[qlog::Metric::CongestionWindow(self.congestion_window)],
524517
now,
525518
);
526519
return true;
@@ -568,9 +561,9 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> {
568561
qlog::metrics_updated(
569562
&self.qlog,
570563
&[
571-
QlogMetric::CongestionWindow(self.congestion_window),
572-
QlogMetric::SsThresh(self.ssthresh),
573-
QlogMetric::InRecovery(true),
564+
qlog::Metric::CongestionWindow(self.congestion_window),
565+
qlog::Metric::SsThresh(self.ssthresh),
566+
qlog::Metric::InRecovery(true),
574567
],
575568
now,
576569
);

neqo-transport/src/qlog.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub fn packets_lost(qlog: &Qlog, pkts: &[sent::Packet], now: Instant) {
298298
}
299299

300300
#[expect(dead_code, reason = "TODO: Construct all variants.")]
301-
pub enum QlogMetric {
301+
pub enum Metric {
302302
MinRtt(Duration),
303303
SmoothedRtt(Duration),
304304
LatestRtt(Duration),
@@ -313,7 +313,7 @@ pub enum QlogMetric {
313313
PacingRate(u64),
314314
}
315315

316-
pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[QlogMetric], now: Instant) {
316+
pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[Metric], now: Instant) {
317317
debug_assert!(!updated_metrics.is_empty());
318318

319319
qlog.add_event_data_with_instant(
@@ -331,24 +331,24 @@ pub fn metrics_updated(qlog: &Qlog, updated_metrics: &[QlogMetric], now: Instant
331331

332332
for metric in updated_metrics {
333333
match metric {
334-
QlogMetric::MinRtt(v) => min_rtt = Some(v.as_secs_f32() * 1000.0),
335-
QlogMetric::SmoothedRtt(v) => smoothed_rtt = Some(v.as_secs_f32() * 1000.0),
336-
QlogMetric::LatestRtt(v) => latest_rtt = Some(v.as_secs_f32() * 1000.0),
337-
QlogMetric::RttVariance(v) => rtt_variance = Some(v.as_secs_f32() * 1000.0),
338-
QlogMetric::PtoCount(v) => {
334+
Metric::MinRtt(v) => min_rtt = Some(v.as_secs_f32() * 1000.0),
335+
Metric::SmoothedRtt(v) => smoothed_rtt = Some(v.as_secs_f32() * 1000.0),
336+
Metric::LatestRtt(v) => latest_rtt = Some(v.as_secs_f32() * 1000.0),
337+
Metric::RttVariance(v) => rtt_variance = Some(v.as_secs_f32() * 1000.0),
338+
Metric::PtoCount(v) => {
339339
pto_count = Some(u16::try_from(*v).expect("fits in u16"));
340340
}
341-
QlogMetric::CongestionWindow(v) => {
341+
Metric::CongestionWindow(v) => {
342342
congestion_window = Some(u64::try_from(*v).expect("fits in u64"));
343343
}
344-
QlogMetric::BytesInFlight(v) => {
344+
Metric::BytesInFlight(v) => {
345345
bytes_in_flight = Some(u64::try_from(*v).expect("fits in u64"));
346346
}
347-
QlogMetric::SsThresh(v) => {
347+
Metric::SsThresh(v) => {
348348
ssthresh = Some(u64::try_from(*v).expect("fits in u64"));
349349
}
350-
QlogMetric::PacketsInFlight(v) => packets_in_flight = Some(*v),
351-
QlogMetric::PacingRate(v) => pacing_rate = Some(*v),
350+
Metric::PacketsInFlight(v) => packets_in_flight = Some(*v),
351+
Metric::PacingRate(v) => pacing_rate = Some(*v),
352352
_ => (),
353353
}
354354
}

neqo-transport/src/recovery/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use token::{StreamRecoveryToken, Token, Tokens};
2828
use crate::{
2929
ecn, packet,
3030
path::{Path, PathRef},
31-
qlog::{self, QlogMetric},
31+
qlog,
3232
rtt::{RttEstimate, RttSource},
3333
stats::{Stats, StatsCell},
3434
tracking::{PacketNumberSpace, PacketNumberSpaceSet},
@@ -808,7 +808,7 @@ impl Loss {
808808

809809
if let Some(st) = &mut self.pto_state {
810810
st.count_pto(&mut self.stats.borrow_mut());
811-
qlog::metrics_updated(&self.qlog, &[QlogMetric::PtoCount(st.count())], now);
811+
qlog::metrics_updated(&self.qlog, &[qlog::Metric::PtoCount(st.count())], now);
812812
}
813813
}
814814

neqo-transport/src/rtt.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ use neqo_common::{qlog::Qlog, qtrace, Buffer};
1515

1616
use crate::{
1717
ackrate::{AckRate, PeerAckDelay},
18-
packet,
19-
qlog::{self, QlogMetric},
20-
recovery,
18+
packet, qlog, recovery,
2119
stats::FrameStats,
2220
};
2321

@@ -143,10 +141,10 @@ impl RttEstimate {
143141
qlog::metrics_updated(
144142
qlog,
145143
&[
146-
QlogMetric::LatestRtt(self.latest_rtt),
147-
QlogMetric::MinRtt(self.min_rtt),
148-
QlogMetric::SmoothedRtt(self.smoothed_rtt),
149-
QlogMetric::RttVariance(self.rttvar),
144+
qlog::Metric::LatestRtt(self.latest_rtt),
145+
qlog::Metric::MinRtt(self.min_rtt),
146+
qlog::Metric::SmoothedRtt(self.smoothed_rtt),
147+
qlog::Metric::RttVariance(self.rttvar),
150148
],
151149
now,
152150
);

0 commit comments

Comments
 (0)