-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
ETA estimate not accurate on long-running processes when the rate changes over the time #247
Comments
Hi @Jylpah, thanks, man! Humm no, there isn't any option to control its responsiveness at the moment. I made a study about it 3 years ago when I was implementing it. It is published here as an Apple Numbers document. Here is a screenshot of it: As you can see, the goal was to minimize abrupt changes, so the ETA seems (and actually gets) more precise.
Perhaps I could let one change this internal configuration? For example, if you set it to What do you think? Thoughts? |
Thank you for your detailed answer, Yes, configurable |
Hi @rsalmei , Did you conclude whether the configurable |
Hi @Jylpah, |
Hello, in the tqdm package they have a parameter to configure that. From the documentation:
I switched to alive-progress just for the animation |
Yikes, really? Half an hour showing ~20s? |
Yep, maybe after 10 min it changes to ~21s, but approximately it stays around the same number for too long, which is not a good time estimate
Correct. I process a lot of files and generally there are more files of a few KB or MB than GB. When it's the turn of a long and heavy video file...
I don't know, with the average that tqdm made I used to like between 0.1 and 0.3, but it's trying and trying until I find an estimate that I like, there is never a perfect one. That's why I missed being able to adjust it to my particular case here 😢 but very good library ❤️ |
Thank you, man. |
Hey @AlberLC, I'm working on this today, but unfortunately, it is not as easy as it seemed. The ETA is based on the Rate value, and both use Exponential Smoothing to get their final values. The rate is actually calculated with: gen_rate = gen_simple_exponential_smoothing(config.rate_alpha, lambda pos, elapsed: pos / elapsed) Can you see it? The input value for the smoothing is "the current position divided by the elapsed time", i.e., I do not capture the instantaneous values at all, so I can't really detect that the current rate is much different than the whole average processing one... 😕 A practical example: with alive_bar(1000) as bar:
for i in range(500):
time.sleep(0.005)
bar() Running this, we can see that the Rate is But if I run this: with alive_bar(1000, rate_alpha=1) as bar:
for i in range(500):
bar()
for i in range(500):
time.sleep(0.005)
bar() We can never receive an instantaneous rate value of Any idea how I could make this happen? |
I have spent more time than I would dare say to understand the problem and the code because my mathematical brain is a little rusty and I am not used to such a functional code (in fact you have taught me that At first I thought that the alpha you were telling me meant that:
y_hat += alfa * (y - y_hat) in
That is, the 1 of
import time
from alive_progress import alive_bar
with alive_bar(1000, rate_alpha=1) as bar:
for i in range(500):
bar()
for i in range(500):
time.sleep(0.005)
bar()
import time
from tqdm import tqdm
with tqdm(total=1000, smoothing=0, mininterval=0) as bar:
for i in range(500):
bar.update()
for i in range(500):
time.sleep(0.005)
bar.update()
Therefore, what I missed about For my case it would be best to always use 1 because I have so many files that the average calculated continuously on the current number of iterations would never cause any changes that were too abrupt, in fact I need it to be even more abrupt to provide an eta that makes sense. Perhaps the way forward would be to merge both methods: apply something similar to what Now, the problem is that |
Hey @AlberLC, I've been thinking about this and made some tests. Screen.Recording.2024-01-28.at.04.47.06.movSo, I'm not sure what to think. It correctly and quickly gets to ~ Regarding the interpretation of the alphas, I'm confused. If I do keep it working with current/instantaneous values, I'd have |
Hi @rsalmei , I finally got my head around the code and attempted to implement the I noticed the "jitter" effect in rate as you mentioned and ended up reducing it by setting a minimum sample for rate update (currently fixed value ProposalUse delta values and set a minimum change for updating the range. Summary of the changes (not a full diff). utils/timing.py elapsed_prev: float = 0.0
total_prev: int = 0
rate_prev: float = 0.0
min_change: int = 3
def calc_rate(total: int, elapsed: float) -> float:
"""
Calculate periodic rate out of total values
"""
global elapsed_prev, total_prev, rate_prev
time: float = elapsed - elapsed_prev
change: int = total - total_prev
if change > min_change: # This is needed to avoid jitter
elapsed_prev = elapsed
total_prev = total
rate_prev = change / time
return rate_prev core/progress.py gen_rate = gen_simple_exponential_smoothing(
config.rate_alpha, lambda pos, elapse: calc_rate(pos, elapse)
) Any comments? If you think the solution has some potential, could you please advice me what parts I am missing still. I am more than happy to create a PR. About alphasThe alphas |
Hello,
first of all a big thanks for a great package. I love ❤️ it. I have noticed that
alive-progress
is very-very slow to react to rate changes in long running processes. I have a batch run that in the beginning runs 60/s, then after maybe 5 hours it drops to 40/s and then maybe few hours it drops to 20/s and continues still ~6 hours. When the real progress is ~20/s,alive-progress
will report ~40/s rate and very-very slowly dropping it leading to false ETA.Is there an option control the responsiveness of the rate estimator? Now the (Moving Average) rate estimator has way too long lead time.
If I am not mistaken, the culprit is this:
alive-progress/alive_progress/core/progress.py
Line 157 in da8454e
This line calculates the rate of the cumulative total vs. total elapsed time vs. calculating it from the difference from the previous change.
The text was updated successfully, but these errors were encountered: