Skip to content

proto: promote recovery metrics to PathStats#2581

Open
JavaPerformance wants to merge 1 commit into
quinn-rs:mainfrom
JavaPerformance:promote-recovery-metrics-to-pathstats
Open

proto: promote recovery metrics to PathStats#2581
JavaPerformance wants to merge 1 commit into
quinn-rs:mainfrom
JavaPerformance:promote-recovery-metrics-to-pathstats

Conversation

@JavaPerformance

Copy link
Copy Markdown

Summary

Promote 6 fields from qlog-only RecoveryMetrics to PathStats, making them available through the zero-overhead Connection::stats() path:

  • bytes_in_flight: u64 — bytes in-flight per congestion control
  • packets_in_flight: u64 — ack-eliciting packets in flight
  • min_rtt: Duration — minimum observed RTT (ignoring ack delay)
  • latest_rtt: Duration — most recent RTT sample
  • rtt_variance: Duration — smoothed RTT variance (RFC 6298)
  • pto_count: u32 — probe timeout event count

Also adds latest() and var() public getters on RttEstimator (min() already existed).

Motivation

These values are already computed internally and surfaced through qlog's MetricsUpdated event. However, accessing them via qlog requires enabling the qlog feature and paying per-event Arc<Mutex> locking + JSON serialization overhead — unsuitable for high-frequency polling in relay/proxy workloads that need to make adaptive decisions (e.g., flow control window sizing based on BDP).

Promoting them to PathStats makes them available with zero additional overhead since stats() already snapshots rtt, cwnd, and current_mtu from the same internal state.

Use cases

  • Adaptive flow control: min_rtt (not smoothed RTT) is the correct input for bandwidth-delay product estimation. bytes_in_flight vs cwnd instantly distinguishes flow-control-limited from congestion-limited connections.
  • Path quality monitoring: latest_rtt + rtt_variance enable jitter detection without qlog.
  • Tail latency diagnosis: pto_count identifies connections experiencing repeated probe timeouts.

Changes

  • quinn-proto/src/connection/stats.rs — 6 new fields on PathStats
  • quinn-proto/src/connection/paths.rs — 2 new pub getters on RttEstimator
  • quinn-proto/src/connection/mod.rs — populate new fields in stats()

All fields use #[non_exhaustive] (inherited from PathStats), so this is backwards-compatible.

Related

Add bytes_in_flight, packets_in_flight, min_rtt, latest_rtt,
rtt_variance, and pto_count to PathStats. These values are already
computed internally for qlog recovery metrics, but accessing them
through qlog requires per-event Arc<Mutex> locking and JSON
serialization — unsuitable for high-frequency polling in relay/proxy
workloads.

Promoting them to PathStats makes them available through the existing
zero-overhead Connection::stats() path.

Also adds public latest() and var() getters on RttEstimator (min()
already existed).

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks okay, modulo one nit.

}

/// Current RTT variance estimate, computed as described in RFC 6298
pub fn var(&self) -> Duration {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think var is a good name for public API...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants