validation: fetch block inputs in parallel

This commit is contained in:
Andrew Toth 2024-11-06 19:52:34 -05:00
parent e8c038c9f6
commit b2da764446
No known key found for this signature in database
GPG key ID: 60007AFC8938B018
2 changed files with 6 additions and 0 deletions

View file

@ -3195,6 +3195,8 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
LogDebug(BCLog::BENCH, " - Load block from disk: %.2fms\n",
Ticks<MillisecondsDouble>(time_2 - time_1));
{
m_chainman.GetInputFetcher().FetchInputs(CoinsTip(), CoinsDB(), blockConnecting);
CCoinsViewCache view(&CoinsTip());
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view);
if (m_chainman.m_options.signals) {
@ -6295,6 +6297,7 @@ static ChainstateManager::Options&& Flatten(ChainstateManager::Options&& opts)
ChainstateManager::ChainstateManager(const util::SignalInterrupt& interrupt, Options options, node::BlockManager::Options blockman_options)
: m_script_check_queue{/*batch_size=*/128, std::clamp(options.worker_threads_num, 0, MAX_SCRIPTCHECK_THREADS)},
m_input_fetcher{/*batch_size=*/128, std::clamp(options.worker_threads_num, 0, MAX_SCRIPTCHECK_THREADS)},
m_interrupt{interrupt},
m_options{Flatten(std::move(options))},
m_blockman{interrupt, std::move(blockman_options)},

View file

@ -13,6 +13,7 @@
#include <consensus/amount.h>
#include <cuckoocache.h>
#include <deploymentstatus.h>
#include <inputfetcher.h>
#include <kernel/chain.h>
#include <kernel/chainparams.h>
#include <kernel/chainstatemanager_opts.h>
@ -951,6 +952,7 @@ private:
//! A queue for script verifications that have to be performed by worker threads.
CCheckQueue<CScriptCheck> m_script_check_queue;
InputFetcher m_input_fetcher;
//! Timers and counters used for benchmarking validation in both background
//! and active chainstates.
@ -1323,6 +1325,7 @@ public:
void RecalculateBestHeader() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
CCheckQueue<CScriptCheck>& GetCheckQueue() { return m_script_check_queue; }
InputFetcher& GetInputFetcher() { return m_input_fetcher; }
~ChainstateManager();
};