-
Notifications
You must be signed in to change notification settings - Fork 38.7k
cli: Add progress bar for -getinfo #22547
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
Conversation
|
Also address #17314
|
Not sure if |
ae5c232 to
38cafb0
Compare
@hebasto thanks for the feedback! I can see where you are coming from but from #17314 I was under the impression that we want to make
|
38cafb0 to
da3603c
Compare
|
Concept ACK. Will try today. |
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'm weak NACK on this.
I'm concept 0 on this
First, thanks for all your work on improving -getinfo 🥃
I think a good way to think about command line tools is how they fit into scripting work flows. We shouldn't add elements that make it harder for someone to extract the needed information as part of their workflow.
The progress bar introduced here is an example of an element that makes it slightly more difficult to extract the needed information; The verification progress value in this case.
Additionally, it is my opinion that the inclusion of this progress bar adds very little value. It doesn't give me any better insight into the verification progress than the number value does.
|
Concept ACK Since "getinfo is no longer part of the RPC API, and client-side implementation is not subject to API stability" (quoting the description in #17314) , its output is meant only to be consumed by humans ("the eye"), not for machines and hence using it ever in a script would obviously be a bad idea that shouldn't be encouraged. For those purposes we have the RPC API. I think CLI users deserves to have a nice looking output as well, I can imagine it's nice to see the verification progress also visually via |
|
No opinion yet about this change. Just mentioning that there is a distinction between client-side CLI commands and the server-side RPC API. IIRC part of the point of the client-side CLI, along with aggregating multiple RPC calls in some cases, is to be human-friendly and freer of API constraints. We warn about software depending on the client-side CLI (for stability it should use the RPC API instead), for instance |
da3603c to
e75ee3e
Compare
|
Concept ACK, nice UX addition for the CLI. Especially neat with |
|
Ok, I tested and TBH find it distracting, somewhat blinding with the large patch of white, and inaccurate. It just adds noise here. Might make more sense in the GUI. If you do keep it, maybe a muted grey instead and not displayed if > 99%. |
e75ee3e to
a94d991
Compare
|
Thanks, reviewers for the feedback and insights! It seems there is a mixed response to this feature. I will leave this PR open for a few more days to get more feedback and close it afterward if there is still no strong demand for it.
@jonatack thanks for the suggestion! Implemented it in e75ee3e to a94d991
|
No progress bar for >= 99% verification makes sense. -\u2588
+\u2592New Unicode for COMPLETE BAR looks good. Tested with command: tACK a94d991 |
theStack
left a comment
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.
Tested ACK a94d99199f17c667ba76fdb77c48ce6136afa81f 📊
Agree that the new (in)complete characters look way better and are less blinding, also displaying the bar only on <99% progress makes sense.
|
@prayank23 Thanks for testing it! I think you're not seeing colour because your stdout is not connected to the terminal. You can get colour if you set |
|
This seems to be a nice improvement over the last version. Some code review feedback here: jonatack@b640049 |
|
tACK a94d99199f17c667ba76fdb77c48ce6136afa81f Nice update. However, @klementtan I'd strongly suggest adding @jonatack's suggestions. For example, I just noticed the lack of space between the progress bar and the percentage value. Additionally, I think the other suggestions there would greatly help readability and simplify future code reviews. Note: I also wasn't getting color from |
029fb9a to
71c1556
Compare
jonatack
left a comment
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.
almost-ACK
|
crACK 71c1556. Will test this week. Changes that I see since last review:
-static std::string GetProgressBar(const double progress)
+void GetProgressBar(double progress, std::string& progress_bar)
-return progress_bar;
-if (progress < 0 || progress > 1) return "";
+if (progress < 0 || progress > 1) return;
-std::string progress_bar = "";
+std::string ibd_progress_bar;
-for (int i = 0; i < progress / INCREMENT; i++) {
+for (int i = 0; i < progress / INCREMENT; ++i) {
-for (int i = 0; i < (1 - progress) / INCREMENT; i++) {
+for (int i = 0; i < (1 - progress) / INCREMENT; ++i) {
I had recently read one post on reddit and found it interesting because of 2 reasons: a. Helped me understand different operators
-verification_progress_bar = GetProgressBar(verification_progress);
+GetProgressBar(ibd_progress, ibd_progress_bar);
+ibd_progress_bar += " "; |
71c1556 to
dba61d0
Compare
|
a94d991 ... dba61d0
@Zero-1729 Thanks for testing! I think you will need to use |
Zero-1729
left a comment
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.
re-tACK dba61d0cd1226fedaef194b6851c34674fda4bd6 🧪
LGTM, great work @klementtan!
Note: Yeah, appending -color=always to bitcoin-cli did the trick, no need for unbuffer again.
Yes this works. I forgot the option that you added in last PR.
|
ghost
left a comment
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.
tACK dba61d0
theStack
left a comment
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.
Some nits after the latest change:
- there is no reason to remove the
staticattribute fromGetProgressBar; the function still only needs to be visible in the same compilation unit - the new interface implictely assumes now that the passed string is already empty, as it only appends to
progress_bar, but never initializes (could either clear the string in the beginning or assert that it is empty?) - I don't think returning a string by value necessarily leads to a copy -- this is a typical case where move semantics potentially kick in and a copy is avoided (see e.g. https://stackoverflow.com/questions/48160292/in-c11-does-returning-a-stdstring-in-a-function-move-or-copy-it); there are also techniques like copy elision and (N)RVO (https://www.fluentcpp.com/2016/11/28/return-value-optimizations/), though I'm not sure if we have any guarantees here with C++17; maybe someone deeper in C++ can shed some light here
Not any blockers though. Will re-test later.
Agree!
IIUC this seems fine, insofar that one might want to append a progress bar to a result string that already has some content.
I hadn't noticed this codebase depending on the compiler for it, though perhaps we already do somewhere. |
Co-authored-by: jonatack <[email protected]>
dba61d0 to
b851a92
Compare
theStack
left a comment
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.
re-ACK b851a92 🍹
(quickly tested watching verification from 0 to 100% on signet)
|
dba61d0 to b851a92: Add |
Agree. It can be changed to non-static if required later. reACK b851a92 |
Zero-1729
left a comment
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.
re-tACK b851a92 (re-tested, works as expected 🍾)
It's a clean push 🪄✨
$ git range-diff dba61d0...b851a92 1: dba61d0cd ! 1: b851a92c0 cli: Add progress bar for -getinfo
...
-+void GetProgressBar(double progress, std::string& progress_bar)
++static void GetProgressBar(double progress, std::string& progress_bar)
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.
ACK b851a92
Tested by manually setting progress inside the new function with values between 0 and 1 and also with
$ ./src/bitcoind -signet -reindex -daemon
$ watch -c -t -n 1 ./src/bitcoin-cli -signet -color=always -getinfo
lsilva01
left a comment
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.
Tested ACK b851a92 on mainnet and signet on Ubuntu 20.04.
Good UX improvement.
shaavan
left a comment
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.
No strong opinion
Tested b851a92 on Ubuntu 20.04
This PR intends on adding a new progress bar in the output of command ./bitcoin-cli -signet -daemon. By adding new functions that create a string of greyscale Unicode characters to give a perception of the progress bar. The ratio of lighter and darker grey tones of these characters is a function of the ratio of the verification process that has been completed.
Tested the PR by the command bitcoind -signet -reindex followed by ./src/bitcoin-cli -signet -getinfo. The PR is successful in adding the changes it intends to add.
Attaching a screenshot to show the proper working of the progress bar in the result of -getinfo
I neither support nor disagree with the changes intended by this PR. Adding a progress bar does make the result of -getinfo command more eye-pleasing, but it doesn’t feel like an important or crucial addition to the result. As the purpose of bitcoin-cli is to be rather highly efficient than being eye-pleasing. If there is some way of adding the progress bar as a suboption of -getinfo then I am ACKed on that, because then the bitcoin-cli user has the choice to rather display the progress bar or not while calling -getinfo.
b851a92 cli: Add progress bar for -getinfo (klementtan) Pull request description: Add a progress bar for the `Verification progress` attribute in `-getinfo` when verification progress `< 99%`.  **Motivation**: * Improve user-friendliness of `-getinfo` * Can be useful with `watch -n 1 bitcoin-cli -getinfo`(suggested by theStack [below](bitcoin#22547 (comment))) * The progress bar is only display when are still syncing to tip(verification progress `< 99%`) **Reviewing** If your verification progress is `> 99%` you can restart the verification progress with ```shell $ ./src/bitcoind -reindex $./src/bitcoin-cli -getinfo ``` ACKs for top commit: prayank23: reACK bitcoin@b851a92 theStack: re-ACK b851a92 🍹 Zero-1729: re-tACK b851a92 (re-tested, works as expected 🍾) jonatack: ACK b851a92 lsilva01: Tested ACK bitcoin@b851a92 on mainnet and signet on Ubuntu 20.04. Tree-SHA512: 2046d812e3c4623c6cc3ed4c24f2daaa92ba12cd181fa21626b782743890c2373be3175cff1441a7ba37295b6d5818368deea90d483959875c22f7ad9b601a20
|
@ShaMan239 Thanks for the detailed review! 👍 I agree that this feature is definitely not essential but from the feedback of other reviewers, it seems that it would make the user experience of using bitcoin-cli better.
For now, I am not really inclined towards adding that because it would make |







Add a progress bar for the
Verification progressattribute in-getinfowhen verification progress< 99%.Motivation:
-getinfowatch -n 1 bitcoin-cli -getinfo(suggested by theStack below)< 99%)Reviewing
If your verification progress is
> 99%you can restart the verification progress with