Sleep for 200us before each ActivateBestChainStep call
This should lower the main thread's likelihood to immediately reacquire cs_main after dropping it, which should help ThreadNotifyWallets and the RPC methods to acquire cs_main more quickly. Ported from ZEC commit e2cd1b761fe556bc6d61849346902c3611530307
This commit is contained in:
11
src/main.cpp
11
src/main.cpp
@@ -33,6 +33,7 @@
|
||||
#include "net.h"
|
||||
#include "netmessagemaker.h"
|
||||
#include "pow.h"
|
||||
#include "time.h"
|
||||
#include "script/interpreter.h"
|
||||
#include "txdb.h"
|
||||
#include "txmempool.h"
|
||||
@@ -4333,7 +4334,15 @@ bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock)
|
||||
CBlockIndex *pindexMostWork = NULL;
|
||||
const CChainParams& chainParams = Params();
|
||||
do {
|
||||
boost::this_thread::interruption_point();
|
||||
// Sleep briefly to allow other threads a chance at grabbing cs_main if
|
||||
// we are connecting a long chain of blocks and would otherwise hold the
|
||||
// lock almost continuously. This helps
|
||||
// the internal wallet, if it is enabled, to keep up with the connected
|
||||
// blocks, reducing the overall time until the node becomes usable.
|
||||
//
|
||||
// This is defined to be an interruption point.
|
||||
// <https://www.boost.org/doc/libs/1_72_0/doc/html/thread/thread_management.html#interruption_points>
|
||||
boost::this_thread::sleep_for(boost::chrono::microseconds(200));
|
||||
|
||||
if (ShutdownRequested())
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user