Merge pull request #6361
4716267
Use real number of cores for default -par, ignore virtual cores (Wladimir J. van der Laan)
This commit is contained in:
commit
d7ada03b8a
5 changed files with 21 additions and 4 deletions
|
@ -283,7 +283,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||
strUsage += HelpMessageOpt("-loadblock=<file>", _("Imports blocks from external blk000??.dat file") + " " + _("on startup"));
|
||||
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
|
||||
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
|
||||
-(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
|
||||
-GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
|
||||
#ifndef WIN32
|
||||
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "bitcoind.pid"));
|
||||
#endif
|
||||
|
@ -772,7 +772,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
|
||||
nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
|
||||
if (nScriptCheckThreads <= 0)
|
||||
nScriptCheckThreads += boost::thread::hardware_concurrency();
|
||||
nScriptCheckThreads += GetNumCores();
|
||||
if (nScriptCheckThreads <= 1)
|
||||
nScriptCheckThreads = 0;
|
||||
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
|
||||
|
|
|
@ -546,7 +546,7 @@ void GenerateBitcoins(bool fGenerate, int nThreads, const CChainParams& chainpar
|
|||
if (Params().DefaultMinerThreads())
|
||||
nThreads = Params().DefaultMinerThreads();
|
||||
else
|
||||
nThreads = boost::thread::hardware_concurrency();
|
||||
nThreads = GetNumCores();
|
||||
}
|
||||
|
||||
if (minerThreads != NULL)
|
||||
|
|
|
@ -42,7 +42,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
|||
/* Main elements init */
|
||||
ui->databaseCache->setMinimum(nMinDbCache);
|
||||
ui->databaseCache->setMaximum(nMaxDbCache);
|
||||
ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency());
|
||||
ui->threadsScriptVerif->setMinimum(-GetNumCores());
|
||||
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
|
||||
|
||||
/* Network elements init */
|
||||
|
|
10
src/util.cpp
10
src/util.cpp
|
@ -756,3 +756,13 @@ void SetThreadPriority(int nPriority)
|
|||
#endif // PRIO_THREAD
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
int GetNumCores()
|
||||
{
|
||||
#if BOOST_VERSION >= 105600
|
||||
return boost::thread::physical_concurrency();
|
||||
#else // Must fall back to hardware_concurrency, which unfortunately counts virtual cores
|
||||
return boost::thread::hardware_concurrency();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,13 @@ std::string HelpMessageGroup(const std::string& message);
|
|||
*/
|
||||
std::string HelpMessageOpt(const std::string& option, const std::string& message);
|
||||
|
||||
/**
|
||||
* Return the number of physical cores available on the current system.
|
||||
* @note This does not count virtual cores, such as those provided by HyperThreading
|
||||
* when boost is newer than 1.56.
|
||||
*/
|
||||
int GetNumCores();
|
||||
|
||||
void SetThreadPriority(int nPriority);
|
||||
void RenameThread(const char* name);
|
||||
|
||||
|
|
Loading…
Reference in a new issue