-
Notifications
You must be signed in to change notification settings - Fork 60
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
progress-bytes #305
progress-bytes #305
Conversation
New version of printing progress (formely #298). No man page or autocompletion yet. This version is cleaner, and applies to
I anticipate some nitpicking over the
|
IIRC you suggested off-line that the There was a suggestion to use |
Yes. And maybe that text could be a bit clearer -- to say that we've processed XXX bytes of archive data, not just XXX bytes from the file we mentioned on the previous line...
Yeah. Using isatty to quiet output automatically is generally an odd thing to do, but it's especially silly when users have explicitly asked for output... |
Do you mean compressed archive data, or uncompressed archive data? The |
I think we decided offline that we want these messages to end up being something like
(with numbers of bytes humanized depending on that option). |
a6e031e
to
44a62ce
Compare
Updated with another DRAFT.
Sample:
Extracting:
|
Is there a reason the first line is at 953 kB? |
@@ -1770,6 +1774,20 @@ dooption(struct bsdtar *bsdtar, const char * conf_opt, | |||
|
|||
bsdtar->option_print_stats = 1; | |||
bsdtar->option_print_stats_set = 1; | |||
} else if (strcmp(conf_opt, "progress-bytes") == 0) { |
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.
And handle --no-progress-bytes?
tar/chunks/chunks_write.c
Outdated
#include "rwhashtab.h" | ||
#include "warnp.h" | ||
|
||
#include "chunks.h" | ||
|
||
uint64_t tarsnap_glob_newbytes = 0; |
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.
Rather than having a global variable, can we pass the chunks cookie to the siginfo code so that it can pull the data out of the chunks layer statistics which we're already keeping?
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 issue is how to link siginfo code and the chunks layer.
- siginfo is all part of
bsdtar.h
. CHUNKS_W
is owned by the multitape layer.
I've sketched a version of what I think you're suggesting, but it has a few WTF moments. I kind-of hope that I misunderstood something.
-
chunks_write_newzbytes()
refers to chunkstats.s_zlen
directly (where previously that was only used inchunks_stats_internal.c
andchunks_directory.c
. [I could fix this by adding achunks_stats_calcznew()
function, but that seemed like overkill at this stage.] -
multitape_write.c
now includesbsdtar.h
, for access to the newsiginfo_setchunks()
. -
siginfo.c
now includeschunks.h
. -
siginfo.c
now contains astatic CHUNKS_W * chunks_write_cookie
.
It might be cleaner to put CHUNKS_W
in struct bsdtar
directly?
On Wed, Apr 11, 2018 at 02:13:57AM +0000, Colin Percival wrote:
Is there a reason the first line is at 953 kB?
It depends on what order files are processed, since siginfo_setinfo() is called
after finishing each file. After adding
```
printf("siginfo_setinfo: %s %zu\n", path, total_uncompressed);
```
I get:
```
$ ./tarsnap --dry-run -c --progress-bytes 300k lib
siginfo_setinfo: lib 0
siginfo_setinfo: lib/crypto 512
siginfo_setinfo: lib/libtarsnap.a 1024
siginfo_setinfo: lib/scryptenc 953856
adding lib/scryptenc
Processed 3 files, 953 kB; New data: 273 kB
```
|
44a62ce
to
ebf1253
Compare
Updated PR with a really questionable (IMO) design. Not for merging. |
tar/siginfo.c
Outdated
* and trigger a siginfo_printinfo() if it exceeds tarsnap_opt_processbytes. | ||
*/ | ||
static void | ||
siginfo_raisetotal(int64_t total) |
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.
Why not take the bsdtar
structure here (or possibly bsdtar->siginfo
)? And put lastprogress
into said structure?
Hmm. Maybe it would be cleaner to pass It's probably a fairly large diff given how many layers the siginfo_data cookie needs to get passed through, but it would avoid the global variable and layering violation. |
This gets way uglier than we realized, because of If we want Looking at tarsnap as an independent program, I think the best bet would be to split off siginfo stuff from bsdtar:
FWIW, |
Ignore the previous comment. (I still think that |
I'm happier with this design. The one part I'm not sold on is passing |
tar/siginfo.c
Outdated
lastprogress = total; | ||
|
||
/* Fake a SIGINFO (no need for an actual signal). */ | ||
siginfo_received = 1; |
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.
Maybe a dumb question, but is there a reason to not call siginfo_printinfo
here?
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.
Oh, we don't have the struct bsdtar
here. But that just raises another question, why isn't this just part of siginfo_setinfo
?
And if we do that, lastprogress
can be part of the siginfo structure rather than being a random static variable here...
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 used static uint64_t lastprogress
because that's what happened in raisesigs()
from tar/storage/storage_write.c
(with lastcheckpoint
). I thought it was a nice solution, actually -- it keeps the variable scope isolated to the code that actually needs it. Are you sure that you'd rather have it inside struct siginfo_data
?
Good point about moving it into siginfo_setinfo()
.
tar/siginfo.c
Outdated
@@ -51,6 +51,15 @@ struct siginfo_data { | |||
/* How large is the archive entry? */ | |||
int64_t size; | |||
|
|||
/* How many files in total? */ |
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.
s/files in total/files have we handled in total/ ?
Or is there a reason this comment is different from the other two?
tar/chunks/chunks_write.c
Outdated
* Start a write transaction using the cache directory ${cachepath} and the | ||
* storage layer cookie ${S} which will involve chunks of maximum size | ||
* ${maxchunksize}. | ||
* ${maxchunksize}. If ${siginfo_newbytes} is not NULL, call it with | ||
* ${siginfo_cookie} and the number of new 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.
That last sentence feels like it ended too soon. "... after writing each chunk"?
Should I rebase these fixes? |
tar/siginfo.c
Outdated
@@ -115,6 +114,7 @@ void | |||
siginfo_setinfo(struct bsdtar *bsdtar, const char * oper, const char * path, | |||
int64_t size, int file_count, uint64_t total_uncompressed) | |||
{ | |||
static uint64_t lastprogress = 0; |
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 used static uint64_t lastprogress
because that's what happened in raisesigs()
from tar/storage/storage_write.c
(with lastcheckpoint
). I thought it was a nice solution, actually -- it keeps the variable scope isolated to the code that actually needs it. Are you sure that you'd rather have it inside struct siginfo_data
?
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.
It's nice for scoping reasons; but it's bad because aside from scope it's a global variable. Singletons should be avoided except when there's a very good reason for them...
It has been too long since I looked at this for me to have any cached context, so please go ahead and tidy up the commit history -- that way it will be clearer when I look at it ab initio. |
Rebased PR. The handling of "new bytes" still feels overly complicated, but given that we're passing info between radically different layers of the program, it might be unavoidable. If you'd like to narrow the scope, I could make a PR that adds a |
No change of functionality; just splitting up the fprintf()s so that the code is easier to understand when there's more items to print.
The public interface siginfo_setinfo() takes int64_t total_uncompressed for consistency with libarchive, but stores that as an (uint64_t) internally because that simplifies the handling inside siginfo and the upcoming tarsnap_opt_progressbytes (next commit).
This is not used anywhere yet, but will be part of printing "new bytes".
This isn't hooked up to the chunks layer yet. We need the extra indirection of void ** siginfo_data because when write.c calls archive_write_open_multitape(), bsdtar->siginfo is still NULL.
bf20c18
to
43ab146
Compare
This is waiting until #313 is accepted first. |
No description provided.