diff --git a/src/checkqueue.h b/src/checkqueue.h index ab1a30be33..44d4b30874 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_CHECKQUEUE_H #define BITCOIN_CHECKQUEUE_H +#include #include #include #include @@ -144,6 +145,7 @@ public: explicit CCheckQueue(unsigned int batch_size, int worker_threads_num) : nBatchSize(batch_size) { + LogInfo("Script verification uses %d additional threads", worker_threads_num); m_worker_threads.reserve(worker_threads_num); for (int n = 0; n < worker_threads_num; ++n) { m_worker_threads.emplace_back([this, n]() { diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp index b86d0b2991..cdc8bdd43e 100644 --- a/src/node/chainstatemanager_args.cpp +++ b/src/node/chainstatemanager_args.cpp @@ -60,8 +60,7 @@ util::Result ApplyArgsManOptions(const ArgsManager& args, ChainstateManage script_threads += GetNumCores(); } // Subtract 1 because the main thread counts towards the par threads. - opts.worker_threads_num = std::clamp(script_threads - 1, 0, MAX_SCRIPTCHECK_THREADS); - LogPrintf("Script verification uses %d additional threads\n", opts.worker_threads_num); + opts.worker_threads_num = script_threads - 1; if (auto max_size = args.GetIntArg("-maxsigcachesize")) { // 1. When supplied with a max_size of 0, both the signature cache and diff --git a/src/node/chainstatemanager_args.h b/src/node/chainstatemanager_args.h index b2cdba68b8..af13aa8d3c 100644 --- a/src/node/chainstatemanager_args.h +++ b/src/node/chainstatemanager_args.h @@ -10,8 +10,6 @@ class ArgsManager; -/** Maximum number of dedicated script-checking threads allowed */ -static constexpr int MAX_SCRIPTCHECK_THREADS{15}; /** -par default (number of script-checking threads, 0 = auto) */ static constexpr int DEFAULT_SCRIPTCHECK_THREADS{0}; diff --git a/src/validation.cpp b/src/validation.cpp index 7656db674a..84c7ed78fe 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -6922,7 +6922,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, options.worker_threads_num}, + : m_script_check_queue{/*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)}, diff --git a/src/validation.h b/src/validation.h index eba54dc9a3..669463029e 100644 --- a/src/validation.h +++ b/src/validation.h @@ -88,6 +88,8 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; * Note that Elements-based parent chains may not have fixes based on this * version check! */ static const int MIN_MAINCHAIN_NODE_VERSION = 160300; // 0.16.3 +/** Maximum number of dedicated script-checking threads allowed */ +static constexpr int MAX_SCRIPTCHECK_THREADS{15}; /** Current sync state passed to tip changed callbacks. */ enum class SynchronizationState {