pub struct CollapseDetector { /* private fields */ }Expand description
Per-connection collapse detector.
Implementations§
Source§impl CollapseDetector
impl CollapseDetector
pub fn new() -> Self
Sourcepub fn observe_rate(&mut self, rate: f64)
pub fn observe_rate(&mut self, rate: f64)
Record an observed instantaneous rate (bytes/s) for this connection.
Sourcepub fn observe_silence(&mut self, since_progress_s: f64, stall_timeout_s: f64)
pub fn observe_silence(&mut self, since_progress_s: f64, stall_timeout_s: f64)
Escalate on wall-clock silence, which no rate sample can express: a connection delivering nothing produces no observations at all.
pub fn mark_dead(&mut self)
pub fn health(&self) -> Health
pub fn samples(&self) -> u32
Sourcepub fn rising(&self) -> bool
pub fn rising(&self) -> bool
Is the rate still climbing?
The short average follows a rising rate within a couple of samples and the long one trails it, so while a connection is still in TCP slow start the two disagree by a wide margin. That disagreement is the honest answer to “is this connection slow?”: not yet known. A repair that reads a climbing rate as a settled one moves work off a connection that was a second away from matching its peers — measured on a 100 ms path, one flow at 16 MB/s against its twin at 49 had 256 MB taken from it, and both were at 90 MB/s before the stolen bytes had been re-requested. The margin is wide enough that steady-state jitter does not trip it and narrow enough that a connection settled at half its peers’ rate is reported as settled, since its two averages agree.
Sourcepub fn reset_after_repair(&mut self)
pub fn reset_after_repair(&mut self)
Clear detection state after work has been moved away, so the next episode is judged on fresh evidence.