Skip to content

Fixes issue #580 #722

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 6 commits into
base: main
Choose a base branch
from
Open

Fixes issue #580 #722

wants to merge 6 commits into from

Conversation

G0rocks
Copy link

@G0rocks G0rocks commented Jul 9, 2025

Here is a new and improved pull request which contains 2 commits.
The first one is from when I was mostly gaining understanding of the code and the second one contains the changes I implemented.

Here is the old pull request:
#721

This should fix issue #580

Detailed explanation

Change ProgressState.eta() function to show ETA before any progress has been made in a way where every second could be the second progress gets made so we assume each step needed will take that much time. This shows in an ETA that grows while no progress has been made after starting a progress bar and settles when the first step is made.

The "sanity check" in Estimator.record() function needed to be removed for this since it prohibited any updates to Estimator parameters if no progress had been made.
The ProgressState.eta() now also includes the time passed since last progress was made in it's ETA calculations and that is what makes the ETA counter count down.

Add sec_per_step to Estimator which is an estimate for how many seconds each step takes.
Also included sec_per_step in the Estimator.reset() function.

Update Estimator.record() function to keep returning the same estimate for how many seconds each step takes even though no progress has been made. This is done so that the ProgressState.eta() function will keep counting down the actual estimated time.
An exception is if the time since the last progress is more than the average time per step then we increase the estimate for how many seconds each step takes by 2% everytime Estimator.record() functino is called. This shows an increase in the ETA at a rate that is much more conservative than the previous rate and in the case of no progress being possible (for example if the progress is for a transmission and the router is unplugged) then the user will clearly see the ETA rise with no hope of it going down. In the case that progress does get done (somebody plugged the router back in) then the actual time it took for progress to be made is used to estimate the time for future steps.

These changes make the parameters Estimator.smoothed_steps_per_sec and Estimator.double_smoothed_steps_per_sec obsolete and unnecessary as well as some functions potentially, like Estimator.steps_per_second() which uses this double exponential smoothing and seems to be only used in the tests/examples and also in the ProgressBar.per_sec() function which I don't know how much is used so I left everything related to these parameters untouched.

G0rocks added 2 commits July 9, 2025 14:28
Simplify ProgressState.duration() function to show the duration regardless of if there is no progress or if the progressbar is finished.
Rename Estimator.prev_steps to steps_done for increased readability
…as been made in a way where every second could be the second progress gets made so we assume each step needed will take that much time. This shows in an ETA that grows while no progress has been made after starting a progress bar and settles when the first step is made.

The "sanity check" in Estimator.record() function needed to be removed for this since it prohibited any updates to Estimator parameters if no progress had been made.
The ProgressState.eta() now also includes the time passed since last progress was made in it's ETA calculations and that is what makes the ETA counter count down.

Add sec_per_step to Estimator which is an estimate for how many seconds each step takes.
Also included sec_per_step in the Estimator.reset() function.

Update Estimator.record() function to keep returning the same estimate for how many seconds each step takes even though no progress has been made. This is done so that the ProgressState.eta() function will keep counting down the actual estimated time.
An exception is if the time since the last progress is more than the average time per step then we increase the estimate for how many seconds each step takes by 2% everytime Estimator.record() functino is called. This shows an increase in the ETA at a rate that is much more conservative than the previous rate and in the case of no progress being possible (for example if the progress is for a transmission and the router is unplugged) then the user will clearly see the ETA rise with no hope of it going down. In the case that progress does get done (somebody plugged the router back in) then the actual time it took for progress to be made is used to estimate the time for future steps.

These changes make the parameters Estimator.smoothed_steps_per_sec and Estimator.double_smoothed_steps_per_sec obsolete and unnecessary as well as some functions potentially, like Estimator.steps_per_second() which uses this double exponential smoothing and seems to be only used in the tests/examples and also in the ProgressBar.per_sec() function which I don't know how much is used so I left everything related to these parameters untouched.
@G0rocks
Copy link
Author

G0rocks commented Jul 9, 2025

@djc How is this?
Let me know if it needs something else to be merged.

@djc
Copy link
Member

djc commented Jul 15, 2025

It's on my list -- not sure when I'll be able to get to it, but pretty sure I will at some point.

@G0rocks
Copy link
Author

G0rocks commented Jul 16, 2025

Great, yeah no stress from my part.
Meanwhile, since you started the workflow (I have very little experience with those) and there was a failed run from cargo fmt --all -- --check I looked up that it suggests formatting changes and I implemented the suggested changes so now hopefully the PR should pass the workflow.

@G0rocks
Copy link
Author

G0rocks commented Jul 16, 2025

There were apparently 2 places I missed with the cargo fmt suggestions but they should be all done now

@G0rocks
Copy link
Author

G0rocks commented Jul 16, 2025

Apparently the cargo fmt workflow does not suggest all the suggestions the first time around, since it had different suggestions this time but I implemented those.

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.

2 participants