Skip to content

Commit 53207d7

Browse files
authored
snapshots: print indexation progress (#2042)
1 parent ca964e5 commit 53207d7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

silkworm/db/snapshot_sync.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "snapshot_sync.hpp"
1818

19+
#include <atomic>
1920
#include <exception>
2021
#include <latch>
2122

@@ -193,14 +194,19 @@ void SnapshotSync::build_missing_indexes() {
193194
return;
194195
}
195196

196-
SILK_INFO << "SnapshotSync: missing indexes detected, rebuild started";
197+
SILK_INFO << "SnapshotSync: " << missing_indexes.size() << " missing indexes to build";
198+
size_t total_tasks = missing_indexes.size();
199+
std::atomic_size_t done_tasks;
197200

198201
for (const auto& index : missing_indexes) {
199-
workers.push_task([=]() {
202+
workers.push_task([index, total_tasks, &done_tasks]() {
200203
try {
201-
SILK_INFO << "SnapshotSync: build index: " << index->path().filename() << " start";
204+
SILK_INFO << "SnapshotSync: building index " << index->path().filename() << " ...";
202205
index->build();
203-
SILK_INFO << "SnapshotSync: build index: " << index->path().filename() << " end";
206+
done_tasks++;
207+
SILK_INFO << "SnapshotSync: built index " << index->path().filename() << ";"
208+
<< " progress: " << (done_tasks * 100 / total_tasks) << "% "
209+
<< done_tasks << " of " << total_tasks << " indexes ready";
204210
} catch (const std::exception& ex) {
205211
SILK_CRIT << "SnapshotSync: build index: " << index->path().filename() << " failed [" << ex.what() << "]";
206212
throw;
@@ -215,6 +221,8 @@ void SnapshotSync::build_missing_indexes() {
215221
// Wait for any already-started-but-unfinished work in case of stop request
216222
workers.pause();
217223
workers.wait_for_tasks();
224+
225+
SILK_INFO << "SnapshotSync: built missing indexes";
218226
}
219227

220228
void SnapshotSync::update_database(db::RWTxn& txn, BlockNum max_block_available) {

0 commit comments

Comments
 (0)