-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optionally show progress while signing. #35
base: use-parallelized-sorting-to-go-faster
Are you sure you want to change the base?
Optionally show progress while signing. #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very cool, but I have different taste in a few aspects apart from the small issues I noted below.
So these are just my personal preferences stated as fact:
- This should be a
MultiProgress
with multiple steps. And we should show at which step it is. - The progress bars should not be cleared.
- Progress bars should not be reused with different messages.
- Spinners should be used for steps where we don't know how long it takes.
if let Some(log) = log { | ||
writeln!( | ||
log, | ||
"Loaded {len} records from {} [{} bytes] in {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the unit of len
here is not records, but bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But records.len()
or something similar should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see the surrounding code on my phone via the GH app.. I think there was one place where I thought the same but was wrong, maybe you are right, but I can't check right now.
} | ||
} | ||
} | ||
|
||
if let Some(pb) = &pb { | ||
pb.set_message("Sorting"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be best to create a new unbounded progress bar here. I'm not seeing this update for some reason.
@@ -474,20 +492,48 @@ impl SignZone { | |||
let (apex, ttl) = Self::find_apex(&records).unwrap(); | |||
|
|||
// Hash the zone with NSEC or NSEC3. | |||
let pb = if matches!(&log, Some(log) if log.is_terminal() && self.progress) { | |||
let pb = ProgressBar::new(0).with_message("Hashing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be ProgressBar::no_length()
and then with slightly different parsing. Also we should call tick()
to make this actually show up, because it doesn't seem to do that by itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried calling tick()
but that also didn't help.
let pb = ProgressBar::new(num_families as u64); | ||
pb.set_draw_target(ProgressDrawTarget::stderr_with_hz(1)); | ||
pb.set_style( | ||
ProgressStyle::with_template(PROGRESS_STYLE) | ||
.unwrap() | ||
.with_key("eta", |state: &ProgressState, w: &mut dyn Write| { | ||
write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap() | ||
}) | ||
.progress_chars("#>-"), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style should probably be saved somewhere so we can reuse it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, there's far too much repetitive boilerplate here, but not being familiar with the progress bar crate I wanted to first get something working.
if let Some(pb) = &pb { | ||
if inc_len > 0 { | ||
pb.inc_length(inc_len as u64); | ||
} | ||
if inc_pos > 0 { | ||
pb.inc(inc_pos as u64); | ||
} | ||
if let Some(new_phase) = new_phase { | ||
pb.set_message(new_phase); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also feels like it should create new progress bars or something.
Thx:
Btw, what does it mean to state preference as fact? 🤪 |
Btw, the large repetitive progress bar construction should be factored out, the code is v messy at present, but I didn't want to spend time on that yet. |
I just meant that I phrased without prefixing everything with "I think" :)
Makes sense yeah. It's kind of satisfying to me, but I understand.
I would work with
Hmmm, but then we should know the total up front right? And maybe the message should then be |
I'm glad I asked. I took it to mean that while it is your preference you believe it not to just be a preference but to be a fact that it should be done that way ;-) |
I will try it out and see what I think of it. |
Signing can be a slow operation.
Prior to this PR there is no feedback at all when signing, one doesn't even know if the signing is stuck or going so slowly that you'd rather stop it than wait.
This PR uses support in
domain
to know how far operations have progressed in combination with theindicatif
crate to output helpful progress bars.Note: This is quick proof-of-concept, it is quite messy at the moment, hence the draft status.
Example appearance: