ConnectTip: don't log total disk read time in bench

This incorrectly assumed num_blocks_total would be greater than 0. This is not guaranteed until the ConnectBlock call right below it.

The total and average metric is not very useful because it does not distinguish between blocks read from disk and those loaded from memory. So rather than fixing the divide by zero issue, we just drop the metric.
This commit is contained in:
Sjors Provoost 2023-05-16 13:15:37 +02:00
parent edd2a86445
commit bc862fad29
No known key found for this signature in database
GPG Key ID: 57FF9BDBCC301009

View File

@ -2760,7 +2760,6 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
return true;
}
static SteadyClock::duration time_read_from_disk_total{};
static SteadyClock::duration time_connect_total{};
static SteadyClock::duration time_flush{};
static SteadyClock::duration time_chainstate{};
@ -2834,12 +2833,11 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
const CBlock& blockConnecting = *pthisBlock;
// Apply the block atomically to the chain state.
const auto time_2{SteadyClock::now()};
time_read_from_disk_total += time_2 - time_1;
SteadyClock::time_point time_3;
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs (%.2fms/blk)]\n",
Ticks<MillisecondsDouble>(time_2 - time_1),
Ticks<SecondsDouble>(time_read_from_disk_total),
Ticks<MillisecondsDouble>(time_read_from_disk_total) / num_blocks_total);
// When adding aggregate statistics in the future, keep in mind that
// num_blocks_total may be zero until the ConnectBlock() call below.
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms\n",
Ticks<MillisecondsDouble>(time_2 - time_1));
{
CCoinsViewCache view(&CoinsTip());
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view);