Skip to content

Commit f467b28

Browse files
committed
Merge bitcoin/bitcoin#27673: log: don't log total disk read time in ConnectTip bench
bc862fa ConnectTip: don't log total disk read time in bench (Sjors Provoost) Pull request description: The " Load block from disk" log introduced in #24216 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. Fixes #27635 ACKs for top commit: MarcoFalke: lgtm ACK bc862fa 🐓 willcl-ark: tACK bc862fa Tree-SHA512: ff52ff8a8a93f1c82071ca84c57ce5839e14271943393deac0aa5555d63383708777ed96e7226be6dd71b63ed07dc27bad1634ee848e88e4d0b95d511a8267e7
2 parents 6cf47a8 + bc862fa commit f467b28

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/validation.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,6 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
27602760
return true;
27612761
}
27622762

2763-
static SteadyClock::duration time_read_from_disk_total{};
27642763
static SteadyClock::duration time_connect_total{};
27652764
static SteadyClock::duration time_flush{};
27662765
static SteadyClock::duration time_chainstate{};
@@ -2834,12 +2833,11 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
28342833
const CBlock& blockConnecting = *pthisBlock;
28352834
// Apply the block atomically to the chain state.
28362835
const auto time_2{SteadyClock::now()};
2837-
time_read_from_disk_total += time_2 - time_1;
28382836
SteadyClock::time_point time_3;
2839-
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs (%.2fms/blk)]\n",
2840-
Ticks<MillisecondsDouble>(time_2 - time_1),
2841-
Ticks<SecondsDouble>(time_read_from_disk_total),
2842-
Ticks<MillisecondsDouble>(time_read_from_disk_total) / num_blocks_total);
2837+
// When adding aggregate statistics in the future, keep in mind that
2838+
// num_blocks_total may be zero until the ConnectBlock() call below.
2839+
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms\n",
2840+
Ticks<MillisecondsDouble>(time_2 - time_1));
28432841
{
28442842
CCoinsViewCache view(&CoinsTip());
28452843
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view);

0 commit comments

Comments
 (0)