Skip to content
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

Merged
merged 10 commits into from
Apr 30, 2021

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Apr 23, 2021

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 😂

image

Updated (2020-04-28)

Current looking

    Updating crates.io index
       Fetch [==>                      ]  14.50%, 258.45KiB/s
       
    Updating crates.io index
       Fetch [======>                  ]  40.50%, (1234/282342) resolving deltas

@rust-highfive
Copy link

r? @Eh2406

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2021
@weihanglo weihanglo changed the title Show transfer progress when fetching/updating registry index Show transfer rate when fetching/updating registry index Apr 23, 2021
Copy link
Member

@alexcrichton alexcrichton left a 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!

src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
@weihanglo
Copy link
Member Author

All updated.

Now it looks like below:

    Updating crates.io index
       Fetch [==>                      ]  14.50%, 258.45KiB/s
       
    Updating crates.io index
       Fetch [======>                  ]  40.50%, (1234/282342) resolving deltas

@alexcrichton alexcrichton added the T-cargo Team: Cargo label Apr 27, 2021
@alexcrichton
Copy link
Member

@rfcbot fcp merge

This affects's Cargo's default UI, so I want to be sure to get sign-off from others as well.

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 27, 2021

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.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Apr 27, 2021
// Receiving objects.
let now = Instant::now();
// Scrape a `received_bytes` to the counter every 300ms.
if now - last_update > Duration::from_millis(300) {
Copy link
Member

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.

Copy link
Member Author

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:

  1. Should we implement another timeout logic to update the transfer rate?
  2. Or do we accept a "constant" transfer rate while encountering network issue?
  3. Is there any other possible solution to handle it?

Copy link
Member

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?

Copy link
Member Author

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!

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 28, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period FCP — a period for last comments before action is taken and removed proposed-final-comment-period An FCP proposal has started, but not yet signed off. labels Apr 28, 2021
@ehuss
Copy link
Contributor

ehuss commented Apr 28, 2021

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 HTTP_TIMEOUT=5, then cargo uses the libcurl backend, which seems to prevent the progress bar from appearing during the download. I don't suppose while looking at this if you maybe saw an obvious reason for that?

@weihanglo
Copy link
Member Author

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 HTTP_TIMEOUT=5, then cargo uses the libcurl backend, which seems to prevent the progress bar from appearing during the download. I don't suppose while looking at this if you maybe saw an obvious reason for that?

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.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Apr 30, 2021

📌 Commit e4d4347 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 30, 2021
@bors
Copy link
Collaborator

bors commented Apr 30, 2021

⌛ Testing commit e4d4347 with merge 6701e33...

@bors
Copy link
Collaborator

bors commented Apr 30, 2021

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing 6701e33 to master...

@bors bors merged commit 6701e33 into rust-lang:master Apr 30, 2021
@weihanglo weihanglo deleted the issue-8483 branch April 30, 2021 15:24
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 1, 2021
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)
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 1, 2021
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
Copy link
Member Author

@ehuss I've created an issue #9444 for the disappearance of progress bar.

@rfcbot rfcbot added finished-final-comment-period FCP complete to-announce and removed final-comment-period FCP — a period for last comments before action is taken labels May 8, 2021
@pickfire
Copy link
Contributor

@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?

@weihanglo
Copy link
Member Author

@pickfire
Here are some examples on 80x24 terminal. The "resolving deltas" part is truncated, which is acceptable for me.

image

image

@ehuss ehuss added this to the 1.54.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge FCP with intent to merge finished-final-comment-period FCP complete S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-cargo Team: Cargo to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Display bytes transferred when updating <crates.io> index
8 participants