0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

bench: Prevent thread oversubscription

This change decreases the variance of benchmark results.
This commit is contained in:
Hennadii Stepanov 2020-08-14 14:58:27 +03:00
parent ce3e6a7cb2
commit 3edc4e34fe
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -14,8 +14,6 @@
#include <vector>
static const int MIN_CORES = 2;
static const size_t BATCHES = 101;
static const size_t BATCH_SIZE = 30;
static const int PREVECTOR_SIZE = 28;
@ -26,6 +24,9 @@ static const unsigned int QUEUE_BATCH_SIZE = 128;
// and there is a little bit of work done between calls to Add.
static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
{
// We shouldn't ever be running with the checkqueue on a single core machine.
if (GetNumCores() <= 1) return;
const ECCVerifyHandle verify_handle;
ECC_Start();
@ -44,7 +45,9 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
};
CCheckQueue<PrevectorJob> queue {QUEUE_BATCH_SIZE};
boost::thread_group tg;
for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
// The main thread should be counted to prevent thread oversubscription, and
// to decrease the variance of benchmark results.
for (auto x = 0; x < GetNumCores() - 1; ++x) {
tg.create_thread([&]{queue.Thread();});
}