-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
progress-bar: use dynamic size units #14423
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
base: master
Are you sure you want to change the base?
Conversation
I like this in general. If the units are the same we could skip intermediate units though and keep the last one. That would make things less verbose and reduce duplication. |
8ba0a5a to
7075567
Compare
|
@xokdvium I've just implemented your suggestion:
I kind of dislike that it is still kind too quiet. How about adding some kind of spinner like with npm or pnpm that indicates that nix is not frozen and still working? |
7075567 to
09e521e
Compare
Sounds great! That could be a separate PR if you'd like. |
src/libutil/include/nix/util/util.hh
Outdated
| throw UsageError("'%s' is not an integer", s); | ||
| } | ||
|
|
||
| size_t getSizeUnit(int64_t value); |
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.
Could we maybe add an enum for the unit? Something like enum class SizeUnit
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.
like its implemented now?
35e1301 to
ba9fd9b
Compare
5b07a5d to
db9a922
Compare
src/libutil/include/nix/util/util.hh
Outdated
| #define SIZE_UNITS \ | ||
| X(Base, 'K') \ |
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.
| #define SIZE_UNITS \ | |
| X(Base, 'K') \ | |
| #define NIX_UTIL_SIZE_UNITS \ | |
| X(Base, 'K') \ |
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 more generous to the out-of-tree users of nix headers. It would also be a good idea to undefine it at the end.
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.
The problem is that it is not directly clear to me where the undefine should be. Because this define is also used in the util.cc file and not only in the util.hh one.
db9a922 to
958bcb5
Compare
958bcb5 to
3a081b6
Compare


Motivation
I've also implemented the changes from #14364 for the progress bar now.
Although it works, I am not quite happy with it.
If I copy something big from one host to another, the total size will probably be >1GiB. The problem now is that the current progress stays as 0 for way too long because the already transferred bytes are still below 0.1GiB.
and after like 10 seconds it looks like that:
This problem could be fixed by not displaying the unit only once for a
X/X/X GiBblock, but instead for every block:X GiB/ X GiB/X GiB.In the reality, this could look like this:
100KiB/25MiB/1GiB. But I am afraid this could be too verbose.Maybe the community or maintainers could express some kind of opinion in the direction this should be going.
Also, this could just be a me-problem, because I am expecting that the number is always changing because it was like that till now.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.