Skip to content

Commit 304ef73

Browse files
committed
validation: improve connect bench logging
1 parent 133f73e commit 304ef73

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/validation.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,9 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
18911891

18921892
static int64_t nTimeCheck = 0;
18931893
static int64_t nTimeForks = 0;
1894-
static int64_t nTimeVerify = 0;
18951894
static int64_t nTimeConnect = 0;
1895+
static int64_t nTimeVerify = 0;
1896+
static int64_t nTimeUndo = 0;
18961897
static int64_t nTimeIndex = 0;
18971898
static int64_t nTimeTotal = 0;
18981899
static int64_t nBlocksTotal = 0;
@@ -2183,6 +2184,9 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
21832184
return false;
21842185
}
21852186

2187+
int64_t nTime5 = GetTimeMicros(); nTimeUndo += nTime5 - nTime4;
2188+
LogPrint(BCLog::BENCH, " - Write undo data: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5 - nTime4), nTimeUndo * MICRO, nTimeUndo * MILLI / nBlocksTotal);
2189+
21862190
if (!pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
21872191
pindex->RaiseValidity(BLOCK_VALID_SCRIPTS);
21882192
m_blockman.m_dirty_blockindex.insert(pindex);
@@ -2192,8 +2196,8 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
21922196
// add this block to the view's block chain
21932197
view.SetBestBlock(pindex->GetBlockHash());
21942198

2195-
int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4;
2196-
LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5 - nTime4), nTimeIndex * MICRO, nTimeIndex * MILLI / nBlocksTotal);
2199+
int64_t nTime6 = GetTimeMicros(); nTimeIndex += nTime6 - nTime5;
2200+
LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime6 - nTime5), nTimeIndex * MICRO, nTimeIndex * MILLI / nBlocksTotal);
21972201

21982202
TRACE6(validation, block_connected,
21992203
block.GetHash().data(),
@@ -2530,7 +2534,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
25302534
return true;
25312535
}
25322536

2533-
static int64_t nTimeReadFromDisk = 0;
2537+
static int64_t nTimeReadFromDiskTotal = 0;
25342538
static int64_t nTimeConnectTotal = 0;
25352539
static int64_t nTimeFlush = 0;
25362540
static int64_t nTimeChainState = 0;
@@ -2598,13 +2602,14 @@ bool CChainState::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew
25982602
}
25992603
pthisBlock = pblockNew;
26002604
} else {
2605+
LogPrint(BCLog::BENCH, " - Using cached block\n");
26012606
pthisBlock = pblock;
26022607
}
26032608
const CBlock& blockConnecting = *pthisBlock;
26042609
// Apply the block atomically to the chain state.
2605-
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
2610+
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDiskTotal += nTime2 - nTime1;
26062611
int64_t nTime3;
2607-
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * MILLI, nTimeReadFromDisk * MICRO);
2612+
LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime2 - nTime1) * MILLI, nTimeReadFromDiskTotal * MICRO, nTimeReadFromDiskTotal * MILLI / nBlocksTotal);
26082613
{
26092614
CCoinsViewCache view(&CoinsTip());
26102615
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view);

0 commit comments

Comments
 (0)