Skip to content
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

Draft
wants to merge 4 commits into
base: use-parallelized-sorting-to-go-faster
Choose a base branch
from

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Nov 25, 2024

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 the indicatif 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:
image

image

@ximon18 ximon18 requested a review from a team November 25, 2024 14:50
Copy link
Contributor

@tertsdiepraam tertsdiepraam left a 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 {}",
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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");
Copy link
Contributor

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");
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines +624 to +633
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("#>-"),
);
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines +525 to +534
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);
}
Copy link
Contributor

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.

@ximon18
Copy link
Member Author

ximon18 commented Nov 25, 2024

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.

Thx:

  • MultiProgress seemed to me (a) to be about concurrent actions which these are not, and (b) likely has some overhead to be thread safe, so I chose not to use it for those reasons.
  • Keeping the progress bar.. I'm not sure. I find the summary afterward more useful and leaving a wide bar across your screen that no longer updates to tell you anything new a bit annoying.
  • The different messages are phases of a single task with progress.
  • I wondered maybe "Sorting" isn't appearing because the sorting operation is so CPU intensive, no I/O or anything, but didn't look into it yet. I wasn't aware of a pure spinner, I wondered about a left-right-left-right bouncing progress bar, or .. don't know, ideally sorting would also report progress as it can be slow on a big zone.

Btw, what does it mean to state preference as fact? 🤪

@ximon18
Copy link
Member Author

ximon18 commented Nov 25, 2024

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.

@tertsdiepraam
Copy link
Contributor

tertsdiepraam commented Nov 25, 2024

Btw, what does it mean to state preference as fact? 🤪

I just meant that I phrased without prefixing everything with "I think" :)

Keeping the progress bar.. I'm not sure. I find the summary afterward more useful and leaving a wide bar across your screen that no longer updates to tell you anything new a bit annoying.

Makes sense yeah. It's kind of satisfying to me, but I understand.

I wondered maybe "Sorting" isn't appearing because the sorting operation is so CPU intensive, no I/O or anything, but didn't look into it yet. I wasn't aware of a pure spinner, I wondered about a left-right-left-right bouncing progress bar, or .. don't know, ideally sorting would also report progress as it can be slow on a big zone.

I would work with steady_tick enabled and as a spinner. The bouncy thing would be cool but I don't think indicatif has that out of the box.

The different messages are phases of a single task with progress.

Hmmm, but then we should know the total up front right? And maybe the message should then be {main_task}: {subtask}

@ximon18
Copy link
Member Author

ximon18 commented Nov 26, 2024

Btw, what does it mean to state preference as fact? 🤪

I just meant that I phrased without prefixing everything with "I think" :)

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 ;-)

@ximon18
Copy link
Member Author

ximon18 commented Nov 26, 2024

Keeping the progress bar.. I'm not sure. I find the summary afterward more useful and leaving a wide bar across your screen that no longer updates to tell you anything new a bit annoying.

Makes sense yeah. It's kind of satisfying to me, but I understand.

I will try it out and see what I think of it.

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