Skip to content

Commit 3edc4e3

Browse files
committed
bench: Prevent thread oversubscription
This change decreases the variance of benchmark results.
1 parent ce3e6a7 commit 3edc4e3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/bench/checkqueue.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
#include <vector>
1616

17-
18-
static const int MIN_CORES = 2;
1917
static const size_t BATCHES = 101;
2018
static const size_t BATCH_SIZE = 30;
2119
static const int PREVECTOR_SIZE = 28;
@@ -26,6 +24,9 @@ static const unsigned int QUEUE_BATCH_SIZE = 128;
2624
// and there is a little bit of work done between calls to Add.
2725
static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
2826
{
27+
// We shouldn't ever be running with the checkqueue on a single core machine.
28+
if (GetNumCores() <= 1) return;
29+
2930
const ECCVerifyHandle verify_handle;
3031
ECC_Start();
3132

@@ -44,7 +45,9 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
4445
};
4546
CCheckQueue<PrevectorJob> queue {QUEUE_BATCH_SIZE};
4647
boost::thread_group tg;
47-
for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
48+
// The main thread should be counted to prevent thread oversubscription, and
49+
// to decrease the variance of benchmark results.
50+
for (auto x = 0; x < GetNumCores() - 1; ++x) {
4851
tg.create_thread([&]{queue.Thread();});
4952
}
5053

0 commit comments

Comments
 (0)