fix: stream model downloads with incremental progress bar#24
Open
fix: stream model downloads with incremental progress bar#24
Conversation
The download_model function buffered the entire HTTP response into memory before updating the progress bar, making large downloads (166MB arcface_r50) appear frozen. Stream chunks directly to disk while updating progress incrementally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the UX of facelock setup model downloads by switching download_model from buffering the full HTTP response in memory to streaming the response to disk while updating the progress bar incrementally.
Changes:
- Stream the blocking
reqwest::Responsebody in ~8KB chunks and write incrementally to the temporary file. - Update the progress bar position during streaming to avoid “frozen” appearance on large downloads.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1359
to
+1363
| let mut downloaded: u64 = 0; | ||
| let mut buffer = vec![0u8; 8192]; | ||
| loop { | ||
| use std::io::Read as _; | ||
| let n = response |
There was a problem hiding this comment.
The use std::io::Read as _; inside the loop is easy to miss and suggests per-iteration work even though it’s only needed to bring the trait into scope. Consider moving the use to just before the loop. Also, since this is purely progress accounting, using pb.inc(n as u64) would let you drop the separate downloaded counter and set_position bookkeeping.
4 tasks
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
download_modelfunction previously buffered the entire HTTP response into memory withresponse.bytes()before writing to disk or updating the progress barstd::io::Readon the blockingreqwest::Response, writing each chunk to the temp file and updating the progress bar incrementally.tmp, then rename), the 600s timeout, the SHA256 verification, and the progress bar style unchangedTest plan
cargo build --workspacepassescargo clippy --workspace -- -D warningspasses with zero warningscargo test --workspacepassesfacelock setupshows live progress during large model downloads instead of appearing frozen🤖 Generated with Claude Code