Skip to main content

Module progress

Module progress 

Source
Expand description

Rolling-window transfer rate and ETA for long-running jobs (downloads, conversions, model loads).

Written from a behavioural description, not from any reference implementation – see docs/plans/ferrox-ui.md.

The whole point is what it refuses to say. Rate is bytes_delta / time_delta, and on the very first tick time_delta is a millisecond or two of a buffered write, which divides out to “123 GB/s” and flashes it at the user before settling. So:

  • a rate is reported only once the window holds at least MIN_SAMPLES samples spanning at least MIN_SPAN_MS; before that the report is stable == false and carries no number at all, which makes the flash structurally impossible rather than merely unlikely;
  • a byte counter that goes backwards (a resumed or restarted transfer) clears the window instead of producing a negative rate;
  • ETA is clamped at zero, because a total that is smaller than the bytes already seen is a metadata bug, not a negative remaining time.

Time is passed in as milliseconds rather than read from a clock, so the behaviour is testable without sleeping.

Structs§

RateEstimator
Rolling window of (timestamp, cumulative bytes) observations.
RateReport
What the UI may display. bytes_per_second and eta_seconds are Some only when stable is true.

Constants§

MIN_SAMPLES
Samples required before a rate is trusted.
MIN_SPAN_MS
Milliseconds the window must span before a rate is trusted.
WINDOW_MS
Samples older than this are dropped, so a rate reflects the recent past rather than the average since the job started.