-
Notifications
You must be signed in to change notification settings - Fork 245
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
ProgressBarIter and finding stream length via seeking breaks rate estimation #480
Comments
I think this is a duplicate of the discussion in #394. It would be great if someone can investigate this in more detail and propose a fix (potentially to revert some |
After some investigation, I've managed to track down the root cause of my issue. While #394 is a discussion of computing ETA, I do not believe it is closely related as that issue does not discuss problems in rate estimation that arise with seeking. I've linked to the relevant lines of code in the Lines 385 to 405 in 791068c
A typical approach of finding the length of a pub fn seek_len(seekable: &mut dyn Seek) -> u64 {
let old_pos = seekable.stream_position().unwrap();
let len = seekable.seek(SeekFrom::End(0)).unwrap();
if old_pos != len {
seekable.seek(SeekFrom::Start(old_pos)).unwrap();
}
// return
len
} This involves 2-3 seek operations:
Unfortunately this seek pattern has unfortunate interactions with the rate estimator:
I can think of two possible solutions:
I am leaning towards the second solution, but I would like to hear other people's opinions before submitting a PR for this. |
Yeah, (2) definitely seems cleaner than (1). Of course it's still kind of a crappy heuristic, but I guess it's unlikely to do much harm. |
MCVE:
Expected behavior: rate hovers slightly below 100/s
Actual behavior: rate is stuck at an absurdly high constant while progress bar counts upwards and drops to slightly below 100/s when the progress bar completes
This behavior could occur when a
ProgressBarIter
is passed to a generic function taking aRead + Seek
object.This is a regression from v0.16.
The text was updated successfully, but these errors were encountered: