diff --git a/csnode/include/csnode/backwardsync.hpp b/csnode/include/csnode/backwardsync.hpp index df64742b5..840c34f95 100644 --- a/csnode/include/csnode/backwardsync.hpp +++ b/csnode/include/csnode/backwardsync.hpp @@ -194,6 +194,12 @@ class BackwardSync { size_t storedSinceFlush_ = 0; uint64_t progressAt_ = 0; size_t progressStored_ = 0; + // the phases of storing since the last progress line, for its averages per block + uint64_t phaseVerifyUs_ = 0; + uint64_t phaseStoreUs_ = 0; + uint64_t phaseConfirmUs_ = 0; + uint64_t phaseTransactions_ = 0; + uint64_t progressBusyUs_ = 0; std::atomic stopped_{false}; std::atomic started_{false}; diff --git a/csnode/src/backwardsync.cpp b/csnode/src/backwardsync.cpp index c98c90402..93726dc06 100644 --- a/csnode/src/backwardsync.cpp +++ b/csnode/src/backwardsync.cpp @@ -239,6 +239,16 @@ void BackwardSync::tick(const Context& ctx) { std::to_string(busyUs_ / 1000) + " ms of processor thread so far (longest turn " + std::to_string(longestTurnUs_ / 1000) + " ms, " + std::to_string(slowTurns_.load()) + " over " + std::to_string(kSlowTurnMs) + " ms; longest flush " + std::to_string(longestFlushUs_ / 1000) + " ms)"); + // where the time of a block goes, on average: what to move off the processor thread next + const uint64_t blocks = std::max(1, stored_ - progressStored_); + const uint64_t busy = busyUs_ - progressBusyUs_; + log("BACKFILL: per block over the last " + std::to_string(blocks) + ": verify " + std::to_string(phaseVerifyUs_ / blocks) + + " us, store " + std::to_string(phaseStoreUs_ / blocks) + " us, confirmations " + std::to_string(phaseConfirmUs_ / blocks) + + " us, " + std::to_string(phaseTransactions_ * 100 / blocks / 100) + "." + + std::to_string(phaseTransactions_ * 100 / blocks % 100 / 10) + " transactions; processor thread busy " + + std::to_string(busy / 10 / std::max(1, t - progressAt_)) + " % of the time"); + phaseVerifyUs_ = phaseStoreUs_ = phaseConfirmUs_ = phaseTransactions_ = 0; + progressBusyUs_ = busyUs_; progressAt_ = t; progressStored_ = stored_; } @@ -641,6 +651,10 @@ void BackwardSync::drain() { if (us > longestTurnUs_) { longestTurnUs_ = us; } + phaseVerifyUs_ += verifyUs; + phaseStoreUs_ += storeUs; + phaseConfirmUs_ += confirmUs; + phaseTransactions_ += transactions; if (now() >= startedMs + kSlowTurnMs) { const size_t n = ++slowTurns_; if (n <= 20 || n % 100 == 0) { diff --git a/docs/CHANGES.md b/docs/CHANGES.md index c22a3c396..f5796d962 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -40,7 +40,9 @@ lines under the new release. ## Not released yet -Nothing yet. +| PR | Change | +|---|---| +| #151 | csnode: every backfill progress line (each 100,000 blocks) is followed by the average cost of a block per phase (verify, store, confirmations), the transactions per block and the share of the processor thread the backfill took | ## community.15 — 2026-11-01