Skip to content

Commit

Permalink
validation: fetch block inputs in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtoth committed Dec 4, 2024
1 parent e4aa843 commit c2e3f6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)},
Expand Down
3 changes: 3 additions & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -951,6 +952,7 @@ class ChainstateManager

//! 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.
Expand Down Expand Up @@ -1323,6 +1325,7 @@ class ChainstateManager
void RecalculateBestHeader() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

CCheckQueue<CScriptCheck>& GetCheckQueue() { return m_script_check_queue; }
InputFetcher& GetInputFetcher() { return m_input_fetcher; }

~ChainstateManager();
};
Expand Down

0 comments on commit c2e3f6e

Please sign in to comment.