Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions datagram-socket/src/socket_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,32 @@ pub struct SocketStats {
pub bytes_retrans: u64,
pub bytes_unsent: u64,
pub delivery_rate: u64,
pub pacing_rate_bytes_per_sec: u64,
pub max_bandwidth: Option<u64>,
pub startup_exit: Option<StartupExit>,
pub bytes_in_flight_duration_us: u64,
/// The amount of available *receive side*, connection level flow
/// control.
pub flow_control_recv_win_bytes: u64,
/// The amount of available *send side*, connection level flow
/// control.
pub flow_control_send_win_bytes: u64,
/// The total number of locally initiated, bidirectional streams
/// that are have ever been opened.
pub local_bidi_streams_opened: u64,
/// The number of locally initiated, bidirectional streams that can
/// be additionally be opened based on the peer's announced
/// stream limit.
pub local_bidi_streams_left: u64,
/// The total number of peer initiated, bidirectional streams
/// that are have ever been opened.
pub peer_bidi_streams_opened: u64,
/// The number of peer initiated, bidirectional streams that can
/// be additionally be opened based on the stream limit we announced
/// to the peer.
pub peer_bidi_streams_left: u64,
/// The total number of streamsthat are closed and have been collected.
pub streams_collected: u64,
}

/// Statistics from when a CCA first exited the startup phase.
Expand Down
40 changes: 40 additions & 0 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7236,6 +7236,15 @@ impl<F: BufFactory> Connection<F> {
stopped_stream_count_remote: self.stopped_stream_remote_count,
path_challenge_rx_count: self.path_challenge_rx_count,
bytes_in_flight_duration: self.bytes_in_flight_duration(),
flow_control_recv_win_bytes: self.max_rx_data() - self.rx_data,
flow_control_send_win_bytes: self.max_tx_data - self.tx_data,
local_bidi_streams_opened: self.streams.local_opened_streams_bidi(),
// yes, peer_streams_left_bidi() is correct.
local_bidi_streams_left: self.streams.peer_streams_left_bidi(),
peer_bidi_streams_opened: self.streams.peer_opened_streams_bidi(),
peer_bidi_streams_left: self.streams.max_streams_bidi() -
self.streams.peer_opened_streams_bidi(),
streams_collected: self.streams.num_collected(),
}
}

Expand Down Expand Up @@ -8756,6 +8765,37 @@ pub struct Stats {
/// Total duration during which this side of the connection was
/// actively sending bytes or waiting for those bytes to be acked.
pub bytes_in_flight_duration: Duration,

/// The amount of available *receive side*, connection level flow
/// control. I.e., the `max_data` we advertised to the peer, less
/// the amount of data receviced.
pub flow_control_recv_win_bytes: u64,

/// The amount of available *send side*, connection level flow
/// control. I.e., the `max_data` limit we received from the peer,
/// less the amount of data sent.
pub flow_control_send_win_bytes: u64,

/// The total number of locally initiated, bidirectional streams
/// that are have ever been opened.
pub local_bidi_streams_opened: u64,

/// The number of locally initiated, bidirectional streams that can
/// be additionally be opened based on the peer's announced
/// stream limit.
pub local_bidi_streams_left: u64,

/// The total number of peer initiated, bidirectional streams
/// that are have ever been opened.
pub peer_bidi_streams_opened: u64,

/// The number of peer initiated, bidirectional streams that can
/// be additionally be opened based on the stream limit we announced
/// to the peer.
pub peer_bidi_streams_left: u64,

/// The total number of streamsthat are closed and have been collected.
pub streams_collected: u64,
}

impl std::fmt::Debug for Stats {
Expand Down
4 changes: 4 additions & 0 deletions quiche/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ impl Path {
stream_retrans_bytes: self.stream_retrans_bytes,
pmtu,
delivery_rate: self.recovery.delivery_rate().to_bytes_per_second(),
pacing_rate_bytes_per_sec: self.recovery.pacing_rate(),
max_bandwidth: self
.recovery
.max_bandwidth()
Expand Down Expand Up @@ -987,6 +988,9 @@ pub struct PathStats {
/// [Pacing]: index.html#pacing
pub delivery_rate: u64,

/// The current pacing rate in bytes/s.
pub pacing_rate_bytes_per_sec: u64,

/// The maximum bandwidth estimate for the connection in bytes/s.
///
/// Note: not all congestion control algorithms provide this metric;
Expand Down
1 change: 0 additions & 1 deletion quiche/src/recovery/congestion/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ impl RecoveryOps for LegacyRecovery {
self.bytes_in_flight.get_duration()
}

#[cfg(test)]
fn pacing_rate(&self) -> u64 {
self.congestion.pacer.rate()
}
Expand Down
1 change: 0 additions & 1 deletion quiche/src/recovery/gcongestion/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,6 @@ impl RecoveryOps for GRecovery {
self.bytes_in_flight.get_duration()
}

#[cfg(test)]
fn pacing_rate(&self) -> u64 {
self.pacer
.pacing_rate(self.bytes_in_flight.get(), &self.rtt_stats)
Expand Down
1 change: 0 additions & 1 deletion quiche/src/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ pub trait RecoveryOps {
#[cfg(test)]
fn in_flight_count(&self, epoch: packet::Epoch) -> usize;

#[cfg(test)]
fn pacing_rate(&self) -> u64;

#[cfg(test)]
Expand Down
15 changes: 15 additions & 0 deletions quiche/src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,16 @@ impl<F: BufFactory> StreamMap<F> {
self.peer_max_streams_uni - self.local_opened_streams_uni
}

/// Returns the number of bidirectional streams that the peer has opened.
pub fn peer_opened_streams_bidi(&self) -> u64 {
self.peer_opened_streams_bidi
}

/// Returns the number of bidirectional streams that the peer has opened.
pub fn local_opened_streams_bidi(&self) -> u64 {
self.local_opened_streams_bidi
}

/// Drops completed stream.
///
/// This should only be called when Stream::is_complete() returns true for
Expand Down Expand Up @@ -621,6 +631,11 @@ impl<F: BufFactory> StreamMap<F> {
self.collected.contains(&stream_id)
}

/// Returns the number of streams that have been collected.
pub fn num_collected(&self) -> u64 {
self.collected.len() as u64
}

/// Returns true if there are any streams that have data to write.
pub fn has_flushable(&self) -> bool {
!self.flushable.is_empty()
Expand Down
12 changes: 12 additions & 0 deletions tokio-quiche/src/quic/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ impl AsSocketStats for QuicConnectionStats {
.as_ref()
.map(|p| p.delivery_rate)
.unwrap_or_default(),
pacing_rate_bytes_per_sec: self
.path_stats
.as_ref()
.map(|p| p.pacing_rate_bytes_per_sec)
.unwrap_or_default(),
max_bandwidth: self.path_stats.as_ref().and_then(|p| p.max_bandwidth),
startup_exit: self
.path_stats
Expand All @@ -177,6 +182,13 @@ impl AsSocketStats for QuicConnectionStats {
.stats
.bytes_in_flight_duration
.as_micros() as u64,
flow_control_recv_win_bytes: self.stats.flow_control_recv_win_bytes,
flow_control_send_win_bytes: self.stats.flow_control_send_win_bytes,
local_bidi_streams_opened: self.stats.local_bidi_streams_opened,
local_bidi_streams_left: self.stats.local_bidi_streams_left,
peer_bidi_streams_opened: self.stats.peer_bidi_streams_opened,
peer_bidi_streams_left: self.stats.peer_bidi_streams_left,
streams_collected: self.stats.streams_collected,
}
}
}
Expand Down
Loading