Skip to content

Commit

Permalink
Clean up console writer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Oct 3, 2023
1 parent 46fd306 commit 1aba214
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/dwarfs/progress.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class progress {
std::atomic<uint64_t> bytes{0};
std::atomic<uint64_t> usec{0};
std::atomic<uint64_t> chunk_size{UINT64_C(16) << 20};
std::atomic<uint64_t> bytes_per_sec{0};
};

class scan_updater {
Expand Down
18 changes: 11 additions & 7 deletions src/dwarfs/console_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void console_writer::update(progress& p, bool last) {
sp.chunk_size.store(std::min(
UINT64_C(1) << 25,
std::max(UINT64_C(1) << 15, std::bit_ceil(bytes_per_second / 32))));
sp.bytes_per_sec.store(bytes_per_second);
}
};

Expand Down Expand Up @@ -246,9 +247,15 @@ void console_writer::update(progress& p, bool last) {
<< newline

<< "original size: " << size_with_unit(p.original_size)
<< ", scanned: " << size_with_unit(p.similarity.bytes)
<< ", hashed: " << size_with_unit(p.hash.bytes) << " ("
<< p.hash.scans << " files)" << newline
<< p.hash.scans << " files, " << size_with_unit(p.hash.bytes_per_sec)
<< "/s)" << newline

<< "scanned: " << size_with_unit(p.similarity.bytes) << " ("
<< p.similarity.scans << " files, "
<< size_with_unit(p.similarity.bytes_per_sec) << "/s)"
<< ", categorizing: " << size_with_unit(p.categorize.bytes_per_sec)
<< "/s" << newline

<< "saved by deduplication: "
<< size_with_unit(p.saved_by_deduplication) << " ("
Expand All @@ -269,10 +276,7 @@ void console_writer::update(progress& p, bool last) {
<< newline

<< "compressed filesystem: " << p.blocks_written << " blocks/"
<< size_with_unit(p.compressed_size) << " written"
<< " [" << size_with_unit(p.hash.chunk_size) << ", "
<< size_with_unit(p.similarity.chunk_size) << ", "
<< size_with_unit(p.categorize.chunk_size) << "]" << newline;
<< size_with_unit(p.compressed_size) << " written" << newline;
break;

case REWRITE:
Expand Down Expand Up @@ -345,7 +349,7 @@ void console_writer::update(progress& p, bool last) {

std::lock_guard lock(log_mutex());

rewind(8 + ctxs.size());
rewind(9 + ctxs.size());

statebuf_ = oss.str();

Expand Down

0 comments on commit 1aba214

Please sign in to comment.