Skip to content

perf(cli): use sliding window for download ETA calculation#22816

Open
joohhnnn wants to merge 2 commits intoparadigmxyz:mainfrom
joohhnnn:improve-download-eta
Open

perf(cli): use sliding window for download ETA calculation#22816
joohhnnn wants to merge 2 commits intoparadigmxyz:mainfrom
joohhnnn:improve-download-eta

Conversation

@joohhnnn
Copy link
Contributor

@joohhnnn joohhnnn commented Mar 5, 2026

The ETA calculation uses cumulative average speed (total_downloaded / total_elapsed), which breaks after a resumable download retry: the downloaded counter jumps instantly to the resume offset while elapsed resets to zero, producing an infinite speed estimate and "ETA: 0s" when minutes of download remain.

Real data from a 239 GB snapshot download with 7 retries (71 min total):

After Retry Progress ETA Displayed Actual Remaining
#2 (18.91%) 45.24 GB 0s ~57 min
#3 (39.49%) 94.48 GB 0s ~42 min
#4 (47.06%) 112.60 GB 0s ~37 min
#5 (64.27%) 153.76 GB 0s ~27 min
#6 (82.74%) 197.95 GB 0s ~16 min
#7 (92.36%) 220.98 GB 0s ~7 min

Root cause: after retry, DownloadProgress is recreated with downloaded = resume_offset but started_at = now, so speed = resume_offset / 0.001s = ∞.

Fix: replace cumulative average with window-relative speed that only counts bytes downloaded within the current 30-second window. On retry, window_downloaded is initialized to the resume offset so previously downloaded bytes are excluded from speed calculation entirely. This also simplifies the code into a single unified speed path and removes the now-unused started_at field.

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant