perf(cli): use sliding window for download ETA calculation#22816
Open
joohhnnn wants to merge 2 commits intoparadigmxyz:mainfrom
Open
perf(cli): use sliding window for download ETA calculation#22816joohhnnn wants to merge 2 commits intoparadigmxyz:mainfrom
joohhnnn wants to merge 2 commits intoparadigmxyz:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
Root cause: after retry,
DownloadProgressis recreated withdownloaded = resume_offsetbutstarted_at = now, sospeed = 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_downloadedis 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-unusedstarted_atfield.