-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show transfer rate when fetching/updating registry index #9395
Conversation
r? @Eh2406 (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks quite nice, thanks for this!
It's ok to not have tests for this, most of Cargo's human-readable terminal UI doesn't have many tests since it's so difficult to do in CI. We as reviewers will check this out to poke around at it and test it manually!
All updated. Now it looks like below:
|
@rfcbot fcp merge This affects's Cargo's default UI, so I want to be sure to get sign-off from others as well. |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
// Receiving objects. | ||
let now = Instant::now(); | ||
// Scrape a `received_bytes` to the counter every 300ms. | ||
if now - last_update > Duration::from_millis(300) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As one thought I had while reading this, do you know if libgit2 is guaranteed to call this callback perioidically? If we receive data and then don't receive anything else for 10s, does that mean the transfer rate is "constant" for that 10s even though we don't actually receive anything?
(basically I think for the transfer rate to be accurate we would have to guarantee that this transfer_progress
callback is called periodically even if the network is idle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that libgit2 does not periodically call the callback. So yes it maybe be stuck. Git CLI has a similar issue too. IIRC all Git operations share the same timeout config from the same curl handle, so its nearly impossible to reuse it. Therefore we have some options:
- Should we implement another timeout logic to update the transfer rate?
- Or do we accept a "constant" transfer rate while encountering network issue?
- Is there any other possible solution to handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our options are pretty limited here. One option is to remove the download rate (boo) and the other one would be to add some sort of threading that calls the update on a tick. I don't think those are really worth it for now though. Perhaps you can leave a comment here to this effect and we can tackle this in the future if it's actually an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added. Also fixed an unit display issue 😂
Thanks for your suggestion!
🔔 This is now entering its final comment period, as per the review above. 🔔 |
This looks great! One question I had unrelated to this PR: I have noticed that the progress bar does not appear if libcurl is being used. For example, if you set the environment variable |
I also noticed that and did some quick tests. Problem probably is not related to cargo. It can be reproduced by registering a simple git2-curl backend to git2's fetch example without any configurations. I'll try to investigate the issue after this one. |
@bors: r+ |
📌 Commit e4d4347 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 7 commits in 4369396ce7d270972955d876eaa4954bea56bcd9..f3e13226d6d17a2bc5f325303494b43a45f53b7f 2021-04-27 14:35:53 +0000 to 2021-04-30 21:50:27 +0000 - Fix problem with metrics test. (rust-lang/cargo#9440) - Show transfer rate when fetching/updating registry index (rust-lang/cargo#9395) - Fix collision doc tests randomly failing. (rust-lang/cargo#9434) - Add missing tracking issues and unstable docs. (rust-lang/cargo#9429) - Fix dep-info files emitting paths relative to deps' roots (rust-lang/cargo#9421) - Upgrade to GitHub-native Dependabot (rust-lang/cargo#9428) - Only deny the `unused_mut` lint (rust-lang/cargo#9425)
Update cargo 7 commits in 4369396ce7d270972955d876eaa4954bea56bcd9..f3e13226d6d17a2bc5f325303494b43a45f53b7f 2021-04-27 14:35:53 +0000 to 2021-04-30 21:50:27 +0000 - Fix problem with metrics test. (rust-lang/cargo#9440) - Show transfer rate when fetching/updating registry index (rust-lang/cargo#9395) - Fix collision doc tests randomly failing. (rust-lang/cargo#9434) - Add missing tracking issues and unstable docs. (rust-lang/cargo#9429) - Fix dep-info files emitting paths relative to deps' roots (rust-lang/cargo#9421) - Upgrade to GitHub-native Dependabot (rust-lang/cargo#9428) - Only deny the `unused_mut` lint (rust-lang/cargo#9425)
@weihanglo can you please show an example of the same progress bar with terminal width 80? I believe some people are still using that (including me). Does it still works nicely? |
@pickfire |
Possibly fixes #8483.
To avoid blinking too frequently, update rate is throttled by one second.
I am not sure how to write tests for it 😂
Updated (2020-04-28)
Current looking