Skip to content

Commit 4f91643

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bench/checkqueue.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ static const unsigned int QUEUE_BATCH_SIZE = 128;
2626
// and there is a little bit of work done between calls to Add.
2727
static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
2828
{
29+
if (GetNumCores() < MIN_CORES) {
30+
return;
31+
}
32+
2933
const ECCVerifyHandle verify_handle;
3034
ECC_Start();
3135

@@ -44,7 +48,9 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
4448
};
4549
CCheckQueue<PrevectorJob> queue {QUEUE_BATCH_SIZE};
4650
boost::thread_group tg;
47-
for (auto x = 0; x < std::max(MIN_CORES, GetNumCores()); ++x) {
51+
// The main thread should be count to prevent thread oversubscription, and
52+
// to decrease the variance of benchmark results.
53+
for (auto x = 0; x < GetNumCores() - 1; ++x) {
4854
tg.create_thread([&]{queue.Thread();});
4955
}
5056

0 commit comments

Comments
 (0)