mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Use real number of cores for default -par, ignore virtual cores
To determine the default for `-par`, the number of script verification threads, use [boost::thread::physical_concurrency()](http://www.boost.org/doc/libs/1_58_0/doc/html/thread/thread_management.html#thread.thread_management.thread.physical_concurrency) which counts only physical cores, not virtual cores. Virtual cores are roughly a set of cached registers to avoid context switches while threading, they cannot actually perform work, so spawning a verification thread for them could even reduce efficiency and will put undue load on the system. Should fix issue #6358, as well as some other reported system overload issues, especially on Intel processors. The function was only introduced in boost 1.56, so provide a utility function `GetNumCores` to fall back for older Boost versions.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user