pub struct Scheduler {
pub stats: Stats,
/* private fields */
}Fields§
§stats: StatsImplementations§
Source§impl Scheduler
impl Scheduler
pub fn new(size: u64, sources: Vec<Source>, conns_per_source: &[usize]) -> Self
pub fn with_theta_scale(self, s: f64) -> Self
Sourcepub fn with_health_ranking(self, on: bool) -> Self
pub fn with_health_ranking(self, on: bool) -> Self
Disable health-ranked victim selection (for A/B measurement only).
pub fn with_stall_timeout(self, t: f64) -> Self
Sourcepub fn mark_done(&mut self, lo: u64, hi: u64)
pub fn mark_done(&mut self, lo: u64, hi: u64)
Mark [lo, hi) as already held, for resuming a partial transfer.
Must be called before the first tick: the initial split assigns all
unassigned work, and bytes already on disk must not be part of it.
Sourcepub fn conn_health(&self, j: usize) -> Health
pub fn conn_health(&self, j: usize) -> Health
Health grade of a connection, for the progress UI and for tests.
Sourcepub fn conn_source(&self, j: usize) -> usize
pub fn conn_source(&self, j: usize) -> usize
Source index a connection belongs to, for the progress UI.
Sourcepub fn conn_rate(&self, j: usize) -> f64
pub fn conn_rate(&self, j: usize) -> f64
Smoothed rate estimate of a connection (bytes/s), for the progress UI.
Sourcepub fn conn_range(&self, j: usize) -> Option<(u64, u64, u64)>
pub fn conn_range(&self, j: usize) -> Option<(u64, u64, u64)>
Active range of a connection, for the progress UI.
pub fn n_conns(&self) -> usize
pub fn is_complete(&self) -> bool
pub fn bytes_held(&self) -> u64
Sourcepub fn held_ranges(&self) -> Vec<(u64, u64)>
pub fn held_ranges(&self) -> Vec<(u64, u64)>
The ranges that are complete on disk, as (lo, hi) pairs.
This is the complement of the unassigned set minus what is still in flight, and it is what a resume record must contain. Reporting only a byte COUNT is not enough: positioned writes land ranges out of order, so “2 MB held” says nothing about which 2 MB, and a resume that assumed a contiguous prefix would skip holes and silently corrupt the file.
Sourcepub fn worst_delta(&self) -> f64
pub fn worst_delta(&self) -> f64
Coverage audit: held + outstanding + unassigned == size.
This is a SAFETY invariant and it does NOT imply liveness – the
livelock this code is written to avoid (a fully-stolen range leaving a
connection idle with a non-empty queue) satisfies it at every instant.
liveness_holds is the property that matters.
The largest measured request setup cost across sources, in seconds.
Exposed because a transport-layer watchdog must express its patience in
units of what a request actually costs on this path rather than as a
hardcoded constant: delta differs by an order of magnitude between a
LAN mirror and a TLS connection through a proxy, and a fixed timeout is
either trigger-happy on the slow path or useless on the fast one.
This is the same quantity the repair deadband is built from
(theta = scale * sqrt(delta * T_rem / n)), so a client that widens
delta widens both together, which is the intended coupling.
Sourcepub fn stall_timeout(&self) -> f64
pub fn stall_timeout(&self) -> f64
The configured stall timeout, in seconds.
pub fn coverage_holds(&self) -> bool
Sourcepub fn liveness_holds(&self) -> bool
pub fn liveness_holds(&self) -> bool
True when some enabled transition strictly decreases the unheld-byte count. False means the scheduler is stuck.
Sourcepub fn on_bytes(&mut self, conn: usize, n: u64, now: f64, dt: f64)
pub fn on_bytes(&mut self, conn: usize, n: u64, now: f64, dt: f64)
Record n bytes arriving on conn at time now over dt seconds.
Convenience wrapper that assumes the arrival is contiguous at the
connection’s cursor. Real transports must use Scheduler::on_bytes_at:
a response still draining from a range that was completed or stolen would
otherwise be credited against whatever range the connection holds NOW,
silently advancing a cursor over bytes that never arrived and leaving a
hole of zeros in the output file.
Sourcepub fn on_bytes_at(&mut self, conn: usize, off: u64, n: u64, now: f64, dt: f64)
pub fn on_bytes_at(&mut self, conn: usize, off: u64, n: u64, now: f64, dt: f64)
Record n bytes that landed at absolute offset off.
Arrivals that do not begin exactly at the connection’s cursor are stale (they belong to a superseded request) and are discarded: the bytes are still written to the file by the transport, but they are not credited, so the scheduler’s coverage accounting stays exact.
Sourcepub fn suspend_source(&mut self, src: usize, until: f64)
pub fn suspend_source(&mut self, src: usize, until: f64)
Suspend a source (429/503 with Retry-After) and reclaim its ranges.