Skip to content

Commit 2ead98e

Browse files
committed
MB-36956: Refactor executorpool_test for multiple ExecutorPools
Modify the tests in executorpool_test.cc to facilitate testing more than just the CB3 ExecutorPool: - Change test fixtures to Typed Test fixtures (although only instantiated with the existing TextExecutorPool). - Rename getBuckets to getTaskables to better reflect the current, more generic form. - Adjust some tests to not rely on implementation details of CB3ExecutorPool. Change-Id: Ia01595b9bf4c2b6c494f0b32615052b495afc8d9 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/133455 Tested-by: Build Bot <[email protected]> Reviewed-by: James Harrison <[email protected]>
1 parent 3267fcb commit 2ead98e

File tree

5 files changed

+159
-138
lines changed

5 files changed

+159
-138
lines changed

engines/ep/src/cb3_executorpool.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ CB3ExecutorPool::CB3ExecutorPool(size_t maxThreads,
8888
totReadyTasks(0),
8989
isHiPrioQset(false),
9090
isLowPrioQset(false),
91-
numBuckets(0),
91+
numTaskables(0),
9292
numSleepers(0),
9393
curWorkers(numTaskSets),
9494
numWorkers(numTaskSets),
@@ -443,7 +443,7 @@ void CB3ExecutorPool::_registerTaskable(Taskable& taskable) {
443443
}
444444

445445
taskOwners.insert(&taskable);
446-
numBuckets++;
446+
numTaskables++;
447447
}
448448

449449
_startWorkers();
@@ -604,15 +604,15 @@ std::vector<ExTask> CB3ExecutorPool::_stopTaskGroup(
604604
std::vector<ExTask> CB3ExecutorPool::_unregisterTaskable(Taskable& taskable,
605605
bool force) {
606606
EP_LOG_INFO("Unregistering {} taskable {}",
607-
(numBuckets == 1) ? "last" : "",
607+
(numTaskables == 1) ? "last" : "",
608608
taskable.getName());
609609

610610
std::unique_lock<std::mutex> lh(tMutex);
611611

612612
auto rv = _stopTaskGroup(taskable.getGID(), lh, force);
613613

614614
taskOwners.erase(&taskable);
615-
if (!(--numBuckets)) {
615+
if (!(--numTaskables)) {
616616
if (!taskLocator.empty()) {
617617
throw std::logic_error(
618618
"CB3ExecutorPool::_unregisterTaskable: "

engines/ep/src/cb3_executorpool.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ class CB3ExecutorPool : public ExecutorPool {
142142
std::vector<ExTask> unregisterTaskable(Taskable& taskable,
143143
bool force) override;
144144

145+
size_t getNumTaskables() const override {
146+
return numTaskables;
147+
}
148+
145149
void doWorkerStat(EventuallyPersistentEngine* engine,
146150
const void* cookie,
147151
const AddStatFn& add_stat) override;
@@ -301,7 +305,8 @@ class CB3ExecutorPool : public ExecutorPool {
301305
TaskQ lpTaskQ; // a vector array of numTaskSets elements for low priority
302306
bool isLowPrioQset;
303307

304-
size_t numBuckets;
308+
// Numbers of registered taskables.
309+
size_t numTaskables;
305310

306311
SyncObject tMutex; // to serialize taskLocator, threadQ, numBuckets access
307312

engines/ep/src/executorpool.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class ExecutorPool {
114114
virtual std::vector<ExTask> unregisterTaskable(Taskable& taskable,
115115
bool force) = 0;
116116

117+
/// @returns the number of registered Taskables.
118+
virtual size_t getNumTaskables() const = 0;
119+
117120
/***************** Task Scheduling **************************************/
118121

119122
/**

0 commit comments

Comments
 (0)