diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-07-01 17:38:15 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-07-01 18:01:16 +0200 |
commit | 47162673c79c757a9c038c4ddc41fb3022223bde (patch) | |
tree | eb472ad23b918630102983ba5ca776e8bb3c7016 /src/util.cpp | |
parent | da77a6f7611f71443914e1c71df1e52468cf507d (diff) |
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.
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index da5821e530..bb7df23205 100644 --- a/src/util.cpp +++ b/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 +} + |