From ae2c2fbaa86de7c1378b1b055a3ad692492080e8 Mon Sep 17 00:00:00 2001 From: Calin Culianu Date: Mon, 7 Jun 2021 04:15:06 +0300 Subject: [PATCH] Remove g_parallel_script_checks global variable This variable is not really used by our codebase -- we always use the CCheckQueue, even if no parallel threads are specified (in that case we use it with the foreground thread). So this variable had no meaning in our codebase. This undoes some of the core backport #17342 --- src/bench/checkqueue.cpp | 2 +- src/init.cpp | 1 - src/test/setup_common.cpp | 3 +-- src/validation.cpp | 3 +-- src/validation.h | 4 ---- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp index c03457c78c..6bfe4e6d83 100644 --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -41,7 +41,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State &state) { void swap(PrevectorJob &x) { p.swap(x.p); }; }; CCheckQueue queue{QUEUE_BATCH_SIZE}; - queue.StartWorkerThreads(std::max(MIN_CORES, GetNumCores())); + queue.StartWorkerThreads(std::max(MIN_CORES, GetNumCores()) - 1); while (state.KeepRunning()) { // Make insecure_rand here so that each iteration is identical. FastRandomContext insecure_rand(true); diff --git a/src/init.cpp b/src/init.cpp index 335cb4c2e2..819afd6e34 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2105,7 +2105,6 @@ bool AppInitMain(Config &config, RPCServer &rpcServer, LogPrintf("Script verification uses %d additional threads\n", script_threads); if (script_threads >= 1) { - g_parallel_script_checks = true; StartScriptCheckWorkerThreads(script_threads); } diff --git a/src/test/setup_common.cpp b/src/test/setup_common.cpp index 4f880e0ebf..3fd290fc06 100644 --- a/src/test/setup_common.cpp +++ b/src/test/setup_common.cpp @@ -122,10 +122,9 @@ TestingSetup::TestingSetup(const std::string &chainName) } } - // Start script-checking threads. Set g_parallel_script_checks to true so they are used. + // Start script-checking threads constexpr int script_check_threads = 2; StartScriptCheckWorkerThreads(script_check_threads); - g_parallel_script_checks = true; g_banman = std::make_unique(GetDataDir() / "banlist.dat", chainparams, diff --git a/src/validation.cpp b/src/validation.cpp index 009539274b..d5402e0597 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -260,7 +260,6 @@ CBlockIndex *pindexBestHeader = nullptr; Mutex g_best_block_mutex; std::condition_variable g_best_block_cv; uint256 g_best_block; -bool g_parallel_script_checks{false}; std::atomic_bool fImporting(false); std::atomic_bool fReindex(false); bool fHavePruned = false; @@ -1892,7 +1891,7 @@ bool CChainState::ConnectBlock(const CBlock &block, CValidationState &state, CBlockUndo blockundo; blockundo.vtxundo.resize(block.vtx.size() - 1); - CCheckQueueControl control(fScriptChecks && g_parallel_script_checks ? &scriptcheckqueue : nullptr); + CCheckQueueControl control(fScriptChecks ? &scriptcheckqueue : nullptr); // Add all outputs try { diff --git a/src/validation.h b/src/validation.h index 036db1b48b..e8aba55a7d 100644 --- a/src/validation.h +++ b/src/validation.h @@ -207,10 +207,6 @@ extern uint256 g_best_block; extern std::atomic_bool fImporting; extern std::atomic_bool fReindex; extern bool fIsBareMultisigStd; -/** Whether there are dedicated script-checking threads running. - * False indicates all script checking is done on the main threadMessageHandler thread. - */ -extern bool g_parallel_script_checks; extern bool fRequireStandard; extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled;