Skip to content

Refactor the DownloadTracker in favor of indicatif #4426

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FranciscoTGouveia
Copy link
Contributor

@FranciscoTGouveia FranciscoTGouveia commented Jul 24, 2025

Closes #1835.

This PR refactors the current manual DownloadTracker progress reporting, replacing it with an indicatif-based implementation, as previously discussed in #1835 and #3828.

This change is a first step toward enabling concurrent component downloads, as the MultiProgress construct of indicatif will very helpful to concurrently report progress.

In terms of performance, benchmarks using hyperfine showed no noticeable difference.
Benchmarks were run 20 times (with 2 warmup runs) over a 50 Mbps connection, each downloading an entire toolchain.

Thanks to @0xPoe and his previous PR, which served as the basis for this change.

Prior art: #2610, #2828, #3349.

@rami3l rami3l self-assigned this Jul 24, 2025
@FranciscoTGouveia FranciscoTGouveia marked this pull request as ready for review July 25, 2025 15:09
@rami3l rami3l force-pushed the refactor-for-indicatif branch from 7ee064c to 6eb8e1a Compare July 25, 2025 16:08
@rami3l
Copy link
Member

rami3l commented Jul 25, 2025

For the reference, the current style is like so on my machine:

image

... and the original goes like:

info: downloading component 'rust-docs'
 20.2 MiB /  20.2 MiB (100 %)  20.1 MiB/s in  1s  

@rami3l
Copy link
Member

rami3l commented Jul 25, 2025

@FranciscoTGouveia I am thinking, the percentage has been replaced by the bar, but the speed meter might still be worth it (and I don't think the timer is that important)?

info: downloading component 'rust-docs'
[███████████████████████████████████████░] 20.09 MiB/20.22 MiB (20.1 MiB/s, ETA: 0s) 

Also, I actually prefer the legacy progress bar style, something closer to pacman or apt:

info: downloading component 'rust-docs'
[####################################    ] 20.09 MiB/20.22 MiB (20.1 MiB/s, ETA: 0s)

@djc @ChrisDenton What would you like (and don't like) to see in this interface that you might see every now and then?

Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR and your prompt update afterwards!

It should be noted though that given the current commit guidelines, any back-and-forth in a single PR should be squashed back to the original commit.

Also, I'd like to wait for my teammates to see if the current style goes for them:

Image

@ChrisDenton
Copy link
Member

I'll admit to not having any strong opinions here but the current style looks fine to me. The ETA can be useful on slower connections so it's clear if you should go and do something else for 20 minutes. Also when the CDN is having issues. Admittedly this can be discerned by looking at the download rate if you're thinking about it.

@FranciscoTGouveia FranciscoTGouveia force-pushed the refactor-for-indicatif branch 2 times, most recently from cbbebb0 to b8dd68e Compare July 26, 2025 18:05
@rami3l rami3l added this to the 1.28.3 milestone Jul 27, 2025
Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the work, your patch works pretty well on my machine!

LGTM modulo some minor suggestions :)

@djc
Copy link
Contributor

djc commented Jul 27, 2025

Also, I actually prefer the legacy progress bar style, something closer to pacman or apt:

Can you explain why?

Comment on lines +75 to +71
if self.progress_bar.is_hidden() && self.progress_bar.elapsed() >= Duration::from_secs(1) {
self.multi_progress_bars.add(self.progress_bar.clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this?

Copy link
Member

@rami3l rami3l Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djc This is to be coherent with the old rustup logic where if a progress is considered to have finished instantly, the corresponding progress bar will remain invisible all along.

Also, the .clone() action is cheap because ProgressBar has referential semantics.

@rami3l
Copy link
Member

rami3l commented Jul 27, 2025

Also, I actually prefer the legacy progress bar style, something closer to pacman or apt:

Can you explain why?

Being a universal tool, we would expect rustup UI to work correctly even if our host doesn't come with proper support for Unicode (this doesn't mean non-ASCII chars are not displayed; but it could mean that they can be shown in a surprising way to be no longer suitable for UI use).

Cargo, for example, has to detect this in case it needs to provide a fallback (thanks, @weihanglo!). The same is true for Python's rich and more. IMHO this is not providing much additional value to our simplification plan, so going with a more traditional solution means we don't have to consider such complexities.

As for the actual character set being used, "## " is my personal preference, but "=> " is another option that I have considered so the progress bar could look more like cargo. UV seems to be using "-- " to be closer to rich and friends.

@FranciscoTGouveia FranciscoTGouveia force-pushed the refactor-for-indicatif branch 2 times, most recently from 483459c to 1a5f8ca Compare July 28, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate using a community maintained progress bar
4 participants