Auto merge of #5167 - str4d:5164-block-bench-fix, r=str4d
Re-include reading blocks from disk in block connection benchmark Fixes a regression introduced in zcash/zcash#4427. Closes zcash/zcash#5164.
This commit is contained in:
commit
c5bb13d35c
16
src/main.cpp
16
src/main.cpp
|
@ -3485,11 +3485,9 @@ uint64_t nNotifiedSequence = 0;
|
||||||
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
|
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
|
||||||
{
|
{
|
||||||
assert(pblock && pindexNew->pprev == chainActive.Tip());
|
assert(pblock && pindexNew->pprev == chainActive.Tip());
|
||||||
int64_t nTime1 = GetTimeMicros();
|
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
|
int64_t nTime2 = GetTimeMicros();
|
||||||
int64_t nTime3;
|
int64_t nTime3;
|
||||||
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
|
||||||
{
|
{
|
||||||
CCoinsViewCache view(pcoinsTip);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
bool rv = ConnectBlock(*pblock, state, pindexNew, view, chainparams);
|
bool rv = ConnectBlock(*pblock, state, pindexNew, view, chainparams);
|
||||||
|
@ -3532,11 +3530,10 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
||||||
|
|
||||||
EnforceNodeDeprecation(pindexNew->nHeight);
|
EnforceNodeDeprecation(pindexNew->nHeight);
|
||||||
|
|
||||||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5;
|
||||||
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
||||||
LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001);
|
// Total connection time benchmarking occurs in ActivateBestChainStep.
|
||||||
MetricsIncrementCounter("zcash.chain.verified.block.total");
|
MetricsIncrementCounter("zcash.chain.verified.block.total");
|
||||||
MetricsHistogram("zcash.chain.verified.block.seconds", (nTime6 - nTime1) * 0.000001);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3698,6 +3695,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
||||||
|
|
||||||
// Connect new blocks.
|
// Connect new blocks.
|
||||||
for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) {
|
for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) {
|
||||||
|
int64_t nTime1 = GetTimeMicros();
|
||||||
const CBlock* pconnectBlock;
|
const CBlock* pconnectBlock;
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (pblock && pindexConnect == pindexMostWork) {
|
if (pblock && pindexConnect == pindexMostWork) {
|
||||||
|
@ -3708,6 +3706,8 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
||||||
return AbortNode(state, "Failed to read block");
|
return AbortNode(state, "Failed to read block");
|
||||||
pconnectBlock = █
|
pconnectBlock = █
|
||||||
}
|
}
|
||||||
|
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
|
||||||
|
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
||||||
|
|
||||||
if (!ConnectTip(state, chainparams, pindexConnect, pconnectBlock)) {
|
if (!ConnectTip(state, chainparams, pindexConnect, pconnectBlock)) {
|
||||||
if (state.IsInvalid()) {
|
if (state.IsInvalid()) {
|
||||||
|
@ -3723,6 +3723,10 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
int64_t nTime3 = GetTimeMicros(); nTimeTotal += nTime3 - nTime1;
|
||||||
|
LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime3 - nTime1) * 0.001, nTimeTotal * 0.000001);
|
||||||
|
MetricsHistogram("zcash.chain.verified.block.seconds", (nTime3 - nTime1) * 0.000001);
|
||||||
|
|
||||||
PruneBlockIndexCandidates();
|
PruneBlockIndexCandidates();
|
||||||
if (!pindexOldTip || chainActive.Tip()->nChainWork > pindexOldTip->nChainWork) {
|
if (!pindexOldTip || chainActive.Tip()->nChainWork > pindexOldTip->nChainWork) {
|
||||||
// We're in a better position than we were. Return temporarily to release the lock.
|
// We're in a better position than we were. Return temporarily to release the lock.
|
||||||
|
|
Loading…
Reference in New Issue