fix: use sliding window for download speed display#1535
Open
ianbmacdonald wants to merge 1 commit intolemonade-sdk:mainfrom
Open
fix: use sliding window for download speed display#1535ianbmacdonald wants to merge 1 commit intolemonade-sdk:mainfrom
ianbmacdonald wants to merge 1 commit intolemonade-sdk:mainfrom
Conversation
c324aae to
691434e
Compare
The download speed display was showing the all-time average (total bytes / total elapsed time), which drastically underreported actual throughput when early portions of the download were slow or there was initial negotiation delay. Switch to a 5-second sliding window: record timestamped byte samples on each progress event, prune samples older than 5s, and compute speed from the window edges. This shows the actual recent throughput. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
691434e to
358bfbf
Compare
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.
Summary
Problem
The Download Manager computed speed as
totalBytes / totalElapsedTime— the average over the entire session. If early portions of the download were slow (API negotiation, initial buffering, HF rate limiting ramp-up), the displayed speed remained far below actual throughput. In testing, btop showed ~925 MiB/s network throughput while the app displayed only 15 MB/s.Changes
src/app/src/renderer/DownloadManager.tsx— AdduseRef-based sliding window sample storage, record samples inhandleDownloadUpdate, clean up in completion/error handlers, rewritecalculateSpeedto use window.Test plan
calculateSpeed)--initially (before 2 samples collected)🤖 Generated with Claude Code