mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Parallelize script verification
* During block verification (when parallelism is requested), script check actions are stored instead of being executed immediately. * After every processed transactions, its signature actions are pushed to a CScriptCheckQueue, which maintains a queue and some synchronization mechanism. * Two or more threads (if enabled) start processing elements from this queue, * When the block connection code is finished processing transactions, it joins the worker pool until the queue is empty. As cs_main is held the entire time, and all verification must be finished before the block continues processing, this does not reach the best possible performance. It is a less drastic change than some more advanced mechanisms (like doing verification out-of-band entirely, and rolling back blocks when a failure is detected). The -par=N flag controls the number of threads (1-16). 0 means auto, and is the default.
This commit is contained in:
@@ -33,9 +33,13 @@ struct TestingSetup {
|
||||
pwalletMain = new CWallet("wallet.dat");
|
||||
pwalletMain->LoadWallet(fFirstRun);
|
||||
RegisterWallet(pwalletMain);
|
||||
nScriptCheckThreads = 3;
|
||||
for (int i=0; i < nScriptCheckThreads-1; i++)
|
||||
NewThread(ThreadScriptCheck, NULL);
|
||||
}
|
||||
~TestingSetup()
|
||||
{
|
||||
ThreadScriptCheckQuit();
|
||||
delete pwalletMain;
|
||||
pwalletMain = NULL;
|
||||
delete pcoinsTip;
|
||||
|
||||
Reference in New Issue
Block a user