summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2016-01-14 12:58:13 -0500
committerJason Rassi <rassi@10gen.com>2016-01-14 15:12:38 -0500
commit09b89f0986550443a13af16b76ef04d91120bb2f (patch)
tree977b1fa1965ac1cba4e6b39b430e309636832305 /src/mongo/db/exec
parent225ac6a226bc34bdae716c17f3b49f5a1a279e4e (diff)
downloadmongo-09b89f0986550443a13af16b76ef04d91120bb2f.tar.gz
SERVER-19377 PlanStage: make work() non-virt, add virt method doWork()
Changes PlanStage::work() to be non-virtual. PlanStage::work() now updates _commonStats and calls new pure virtual method doWork().
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/and_hash.cpp24
-rw-r--r--src/mongo/db/exec/and_hash.h2
-rw-r--r--src/mongo/db/exec/and_sorted.cpp22
-rw-r--r--src/mongo/db/exec/and_sorted.h2
-rw-r--r--src/mongo/db/exec/cached_plan.cpp20
-rw-r--r--src/mongo/db/exec/cached_plan.h2
-rw-r--r--src/mongo/db/exec/collection_scan.cpp11
-rw-r--r--src/mongo/db/exec/collection_scan.h2
-rw-r--r--src/mongo/db/exec/count.cpp9
-rw-r--r--src/mongo/db/exec/count.h2
-rw-r--r--src/mongo/db/exec/count_scan.cpp8
-rw-r--r--src/mongo/db/exec/count_scan.h2
-rw-r--r--src/mongo/db/exec/delete.cpp17
-rw-r--r--src/mongo/db/exec/delete.h2
-rw-r--r--src/mongo/db/exec/distinct_scan.cpp8
-rw-r--r--src/mongo/db/exec/distinct_scan.h2
-rw-r--r--src/mongo/db/exec/ensure_sorted.cpp15
-rw-r--r--src/mongo/db/exec/ensure_sorted.h2
-rw-r--r--src/mongo/db/exec/eof.cpp5
-rw-r--r--src/mongo/db/exec/eof.h2
-rw-r--r--src/mongo/db/exec/fetch.cpp17
-rw-r--r--src/mongo/db/exec/fetch.h2
-rw-r--r--src/mongo/db/exec/group.cpp11
-rw-r--r--src/mongo/db/exec/group.h2
-rw-r--r--src/mongo/db/exec/idhack.cpp10
-rw-r--r--src/mongo/db/exec/idhack.h2
-rw-r--r--src/mongo/db/exec/index_iterator.cpp8
-rw-r--r--src/mongo/db/exec/index_iterator.h2
-rw-r--r--src/mongo/db/exec/index_scan.cpp11
-rw-r--r--src/mongo/db/exec/index_scan.h2
-rw-r--r--src/mongo/db/exec/keep_mutations.cpp17
-rw-r--r--src/mongo/db/exec/keep_mutations.h2
-rw-r--r--src/mongo/db/exec/limit.cpp11
-rw-r--r--src/mongo/db/exec/limit.h2
-rw-r--r--src/mongo/db/exec/merge_sort.cpp16
-rw-r--r--src/mongo/db/exec/merge_sort.h2
-rw-r--r--src/mongo/db/exec/multi_iterator.cpp2
-rw-r--r--src/mongo/db/exec/multi_iterator.h2
-rw-r--r--src/mongo/db/exec/multi_plan.cpp15
-rw-r--r--src/mongo/db/exec/multi_plan.h2
-rw-r--r--src/mongo/db/exec/near.cpp11
-rw-r--r--src/mongo/db/exec/near.h2
-rw-r--r--src/mongo/db/exec/oplogstart.cpp2
-rw-r--r--src/mongo/db/exec/oplogstart.h2
-rw-r--r--src/mongo/db/exec/or.cpp14
-rw-r--r--src/mongo/db/exec/or.h2
-rw-r--r--src/mongo/db/exec/pipeline_proxy.cpp2
-rw-r--r--src/mongo/db/exec/pipeline_proxy.h2
-rw-r--r--src/mongo/db/exec/plan_stage.cpp19
-rw-r--r--src/mongo/db/exec/plan_stage.h7
-rw-r--r--src/mongo/db/exec/projection.cpp11
-rw-r--r--src/mongo/db/exec/projection.h2
-rw-r--r--src/mongo/db/exec/queued_data_stage.cpp10
-rw-r--r--src/mongo/db/exec/queued_data_stage.h2
-rw-r--r--src/mongo/db/exec/shard_filter.cpp12
-rw-r--r--src/mongo/db/exec/shard_filter.h2
-rw-r--r--src/mongo/db/exec/skip.cpp12
-rw-r--r--src/mongo/db/exec/skip.h2
-rw-r--r--src/mongo/db/exec/sort.cpp13
-rw-r--r--src/mongo/db/exec/sort.h2
-rw-r--r--src/mongo/db/exec/sort_key_generator.cpp12
-rw-r--r--src/mongo/db/exec/sort_key_generator.h2
-rw-r--r--src/mongo/db/exec/subplan.cpp19
-rw-r--r--src/mongo/db/exec/subplan.h2
-rw-r--r--src/mongo/db/exec/text.cpp26
-rw-r--r--src/mongo/db/exec/text.h2
-rw-r--r--src/mongo/db/exec/text_match.cpp22
-rw-r--r--src/mongo/db/exec/text_match.h2
-rw-r--r--src/mongo/db/exec/text_or.cpp22
-rw-r--r--src/mongo/db/exec/text_or.h2
-rw-r--r--src/mongo/db/exec/update.cpp21
-rw-r--r--src/mongo/db/exec/update.h2
72 files changed, 103 insertions, 459 deletions
diff --git a/src/mongo/db/exec/and_hash.cpp b/src/mongo/db/exec/and_hash.cpp
index 911ec6482cb..8153359ce89 100644
--- a/src/mongo/db/exec/and_hash.cpp
+++ b/src/mongo/db/exec/and_hash.cpp
@@ -107,12 +107,7 @@ bool AndHashStage::isEOF() {
_children[_children.size() - 1]->isEOF();
}
-PlanStage::StageState AndHashStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState AndHashStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -233,7 +228,6 @@ PlanStage::StageState AndHashStage::work(WorkingSetID* out) {
if (_dataMap.end() == it) {
// Child's output wasn't in every previous child. Throw it out.
_ws->free(*out);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else {
// Child's output was in every previous child. Merge any key data in
@@ -244,7 +238,6 @@ PlanStage::StageState AndHashStage::work(WorkingSetID* out) {
AndCommon::mergeFrom(_ws, hashID, *member);
_ws->free(*out);
- ++_commonStats.advanced;
*out = hashID;
return PlanStage::ADVANCED;
}
@@ -281,7 +274,6 @@ PlanStage::StageState AndHashStage::readFirstChild(WorkingSetID* out) {
// happen if we're seeing a newer copy of the same doc in a more recent snapshot.
// Throw out the newer copy of the doc.
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -291,7 +283,6 @@ PlanStage::StageState AndHashStage::readFirstChild(WorkingSetID* out) {
// Update memory stats.
_memUsage += member->getMemUsage();
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == childStatus) {
// Done reading child 0.
@@ -303,7 +294,6 @@ PlanStage::StageState AndHashStage::readFirstChild(WorkingSetID* out) {
return PlanStage::IS_EOF;
}
- ++_commonStats.needTime;
_specificStats.mapAfterChild.push_back(_dataMap.size());
return PlanStage::NEED_TIME;
@@ -320,10 +310,7 @@ PlanStage::StageState AndHashStage::readFirstChild(WorkingSetID* out) {
}
return childStatus;
} else {
- if (PlanStage::NEED_TIME == childStatus) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == childStatus) {
- ++_commonStats.needYield;
+ if (PlanStage::NEED_YIELD == childStatus) {
*out = id;
}
@@ -363,7 +350,6 @@ PlanStage::StageState AndHashStage::hashOtherChildren(WorkingSetID* out) {
_memUsage += olderMember->getMemUsage() - memUsageBefore;
}
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == childStatus) {
// Finished with a child.
@@ -404,7 +390,6 @@ PlanStage::StageState AndHashStage::hashOtherChildren(WorkingSetID* out) {
_hashingChildren = false;
}
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) {
*out = id;
@@ -419,10 +404,7 @@ PlanStage::StageState AndHashStage::hashOtherChildren(WorkingSetID* out) {
}
return childStatus;
} else {
- if (PlanStage::NEED_TIME == childStatus) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == childStatus) {
- ++_commonStats.needYield;
+ if (PlanStage::NEED_YIELD == childStatus) {
*out = id;
}
diff --git a/src/mongo/db/exec/and_hash.h b/src/mongo/db/exec/and_hash.h
index 8f888fb17ab..ba57866ac28 100644
--- a/src/mongo/db/exec/and_hash.h
+++ b/src/mongo/db/exec/and_hash.h
@@ -69,7 +69,7 @@ public:
*/
size_t getMemUsage() const;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/and_sorted.cpp b/src/mongo/db/exec/and_sorted.cpp
index edc0450b214..576141e6259 100644
--- a/src/mongo/db/exec/and_sorted.cpp
+++ b/src/mongo/db/exec/and_sorted.cpp
@@ -63,12 +63,7 @@ bool AndSortedStage::isEOF() {
return _isEOF;
}
-PlanStage::StageState AndSortedStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState AndSortedStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -123,7 +118,6 @@ PlanStage::StageState AndSortedStage::getTargetLoc(WorkingSetID* out) {
_workingTowardRep.push(i);
}
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == state) {
_isEOF = true;
@@ -142,10 +136,7 @@ PlanStage::StageState AndSortedStage::getTargetLoc(WorkingSetID* out) {
_isEOF = true;
return state;
} else {
- if (PlanStage::NEED_TIME == state) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == state) {
- ++_commonStats.needYield;
+ if (PlanStage::NEED_YIELD == state) {
*out = id;
}
@@ -191,17 +182,14 @@ PlanStage::StageState AndSortedStage::moveTowardTargetLoc(WorkingSetID* out) {
_targetLoc = RecordId();
*out = toReturn;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
// More children need to be advanced to _targetLoc.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (member->loc < _targetLoc) {
// The front element of _workingTowardRep hasn't hit the thing we're AND-ing with
// yet. Try again later.
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else {
// member->loc > _targetLoc.
@@ -224,7 +212,6 @@ PlanStage::StageState AndSortedStage::moveTowardTargetLoc(WorkingSetID* out) {
}
}
// Need time to chase after the new _targetLoc.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
} else if (PlanStage::IS_EOF == state) {
@@ -246,10 +233,7 @@ PlanStage::StageState AndSortedStage::moveTowardTargetLoc(WorkingSetID* out) {
_ws->free(_targetId);
return state;
} else {
- if (PlanStage::NEED_TIME == state) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == state) {
- ++_commonStats.needYield;
+ if (PlanStage::NEED_YIELD == state) {
*out = id;
}
diff --git a/src/mongo/db/exec/and_sorted.h b/src/mongo/db/exec/and_sorted.h
index 3ea040b0428..d8edfcd21c6 100644
--- a/src/mongo/db/exec/and_sorted.h
+++ b/src/mongo/db/exec/and_sorted.h
@@ -57,7 +57,7 @@ public:
void addChild(PlanStage* child);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/cached_plan.cpp b/src/mongo/db/exec/cached_plan.cpp
index 8206ffac464..45977701402 100644
--- a/src/mongo/db/exec/cached_plan.cpp
+++ b/src/mongo/db/exec/cached_plan.cpp
@@ -280,12 +280,7 @@ bool CachedPlanStage::isEOF() {
return _results.empty() && child()->isEOF();
}
-PlanStage::StageState CachedPlanStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState CachedPlanStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -294,22 +289,11 @@ PlanStage::StageState CachedPlanStage::work(WorkingSetID* out) {
if (!_results.empty()) {
*out = _results.front();
_results.pop_front();
- _commonStats.advanced++;
return PlanStage::ADVANCED;
}
// Nothing left in trial period buffer.
- StageState childStatus = child()->work(out);
-
- if (PlanStage::ADVANCED == childStatus) {
- _commonStats.advanced++;
- } else if (PlanStage::NEED_YIELD == childStatus) {
- _commonStats.needYield++;
- } else if (PlanStage::NEED_TIME == childStatus) {
- _commonStats.needTime++;
- }
-
- return childStatus;
+ return child()->work(out);
}
void CachedPlanStage::doInvalidate(OperationContext* txn,
diff --git a/src/mongo/db/exec/cached_plan.h b/src/mongo/db/exec/cached_plan.h
index d9f54716acb..e065b955012 100644
--- a/src/mongo/db/exec/cached_plan.h
+++ b/src/mongo/db/exec/cached_plan.h
@@ -63,7 +63,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp
index 74d64c39cc8..634fec6e00d 100644
--- a/src/mongo/db/exec/collection_scan.cpp
+++ b/src/mongo/db/exec/collection_scan.cpp
@@ -68,12 +68,7 @@ CollectionScan::CollectionScan(OperationContext* txn,
_specificStats.direction = params.direction;
}
-PlanStage::StageState CollectionScan::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) {
if (_isDead) {
Status status(
ErrorCodes::CappedPositionLost,
@@ -118,7 +113,6 @@ PlanStage::StageState CollectionScan::work(WorkingSetID* out) {
}
}
- _commonStats.needTime++;
return PlanStage::NEED_TIME;
}
@@ -132,7 +126,6 @@ PlanStage::StageState CollectionScan::work(WorkingSetID* out) {
WorkingSetMember* member = _workingSet->get(_wsidForFetch);
member->setFetcher(fetcher.release());
*out = _wsidForFetch;
- _commonStats.needYield++;
return PlanStage::NEED_YIELD;
}
@@ -177,11 +170,9 @@ PlanStage::StageState CollectionScan::returnIfMatches(WorkingSetMember* member,
if (Filter::passes(member, _filter)) {
*out = memberID;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else {
_workingSet->free(memberID);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
diff --git a/src/mongo/db/exec/collection_scan.h b/src/mongo/db/exec/collection_scan.h
index 30a3f11af34..a1f076f8d27 100644
--- a/src/mongo/db/exec/collection_scan.h
+++ b/src/mongo/db/exec/collection_scan.h
@@ -54,7 +54,7 @@ public:
WorkingSet* workingSet,
const MatchExpression* filter);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp
index 269449d4a1b..c71d87cdba6 100644
--- a/src/mongo/db/exec/count.cpp
+++ b/src/mongo/db/exec/count.cpp
@@ -95,12 +95,7 @@ void CountStage::trivialCount() {
_specificStats.trivialCount = true;
}
-PlanStage::StageState CountStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState CountStage::doWork(WorkingSetID* out) {
// This stage never returns a working set member.
*out = WorkingSet::INVALID_ID;
@@ -154,11 +149,9 @@ PlanStage::StageState CountStage::work(WorkingSetID* out) {
}
} else if (PlanStage::NEED_YIELD == state) {
*out = id;
- _commonStats.needYield++;
return PlanStage::NEED_YIELD;
}
- _commonStats.needTime++;
return PlanStage::NEED_TIME;
}
diff --git a/src/mongo/db/exec/count.h b/src/mongo/db/exec/count.h
index 63c37face02..e083eb59aff 100644
--- a/src/mongo/db/exec/count.h
+++ b/src/mongo/db/exec/count.h
@@ -54,7 +54,7 @@ public:
PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_COUNT;
diff --git a/src/mongo/db/exec/count_scan.cpp b/src/mongo/db/exec/count_scan.cpp
index d4a9638c322..035f6b15a02 100644
--- a/src/mongo/db/exec/count_scan.cpp
+++ b/src/mongo/db/exec/count_scan.cpp
@@ -64,14 +64,10 @@ CountScan::CountScan(OperationContext* txn, const CountScanParams& params, Worki
}
-PlanStage::StageState CountScan::work(WorkingSetID* out) {
- ++_commonStats.works;
+PlanStage::StageState CountScan::doWork(WorkingSetID* out) {
if (_commonStats.isEOF)
return PlanStage::IS_EOF;
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
boost::optional<IndexKeyEntry> entry;
const bool needInit = !_cursor;
try {
@@ -106,12 +102,10 @@ PlanStage::StageState CountScan::work(WorkingSetID* out) {
if (_shouldDedup && !_returned.insert(entry->loc).second) {
// *loc was already in _returned.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
*out = WorkingSet::INVALID_ID;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/count_scan.h b/src/mongo/db/exec/count_scan.h
index 7bc593d0695..b470130beb8 100644
--- a/src/mongo/db/exec/count_scan.h
+++ b/src/mongo/db/exec/count_scan.h
@@ -68,7 +68,7 @@ class CountScan final : public PlanStage {
public:
CountScan(OperationContext* txn, const CountScanParams& params, WorkingSet* workingSet);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp
index 5a070fcdc0b..366ab76f108 100644
--- a/src/mongo/db/exec/delete.cpp
+++ b/src/mongo/db/exec/delete.cpp
@@ -78,12 +78,7 @@ bool DeleteStage::isEOF() {
child()->isEOF();
}
-PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState DeleteStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -100,7 +95,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
*out = _idReturning;
_idReturning = WorkingSet::INVALID_ID;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
@@ -130,12 +124,10 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
return status;
case PlanStage::NEED_TIME:
- ++_commonStats.needTime;
return status;
case PlanStage::NEED_YIELD:
*out = id;
- ++_commonStats.needYield;
return status;
case PlanStage::IS_EOF:
@@ -165,7 +157,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
}
++_specificStats.nInvalidateSkips;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
RecordId rloc = member->loc;
@@ -181,7 +172,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
cursor = _collection->getCursor(getOpCtx());
if (!WorkingSetCommon::fetch(getOpCtx(), _ws, id, cursor)) {
// Doc is already deleted. Nothing more to do.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -189,7 +179,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
if (_params.canonicalQuery &&
!_params.canonicalQuery->root()->matchesBSON(member->obj.value(), NULL)) {
// Doesn't match.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
@@ -237,7 +226,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
_idRetrying = id;
memberFreer.Dismiss(); // Keep this member around so we can retry deleting it.
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -266,7 +254,6 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
memberFreer.Dismiss();
}
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -276,11 +263,9 @@ PlanStage::StageState DeleteStage::work(WorkingSetID* out) {
memberFreer.Dismiss(); // Keep this member around so we can return it.
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
diff --git a/src/mongo/db/exec/delete.h b/src/mongo/db/exec/delete.h
index 9b99b7f813b..55879182adb 100644
--- a/src/mongo/db/exec/delete.h
+++ b/src/mongo/db/exec/delete.h
@@ -83,7 +83,7 @@ public:
PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/distinct_scan.cpp b/src/mongo/db/exec/distinct_scan.cpp
index dcbbfd4aabf..109e1e256ed 100644
--- a/src/mongo/db/exec/distinct_scan.cpp
+++ b/src/mongo/db/exec/distinct_scan.cpp
@@ -67,14 +67,10 @@ DistinctScan::DistinctScan(OperationContext* txn,
_commonStats.isEOF = !_checker.getStartSeekPoint(&_seekPoint);
}
-PlanStage::StageState DistinctScan::work(WorkingSetID* out) {
- ++_commonStats.works;
+PlanStage::StageState DistinctScan::doWork(WorkingSetID* out) {
if (_commonStats.isEOF)
return PlanStage::IS_EOF;
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
boost::optional<IndexKeyEntry> kv;
try {
if (!_cursor)
@@ -95,7 +91,6 @@ PlanStage::StageState DistinctScan::work(WorkingSetID* out) {
switch (_checker.checkKey(kv->key, &_seekPoint)) {
case IndexBoundsChecker::MUST_ADVANCE:
// Try again next time. The checker has adjusted the _seekPoint.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
case IndexBoundsChecker::DONE:
@@ -122,7 +117,6 @@ PlanStage::StageState DistinctScan::work(WorkingSetID* out) {
_workingSet->transitionToLocAndIdx(id);
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
invariant(false);
diff --git a/src/mongo/db/exec/distinct_scan.h b/src/mongo/db/exec/distinct_scan.h
index d915af433cc..a82815a3793 100644
--- a/src/mongo/db/exec/distinct_scan.h
+++ b/src/mongo/db/exec/distinct_scan.h
@@ -76,7 +76,7 @@ class DistinctScan final : public PlanStage {
public:
DistinctScan(OperationContext* txn, const DistinctParams& params, WorkingSet* workingSet);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/ensure_sorted.cpp b/src/mongo/db/exec/ensure_sorted.cpp
index 9b6cfc87aa4..e57cc61727c 100644
--- a/src/mongo/db/exec/ensure_sorted.cpp
+++ b/src/mongo/db/exec/ensure_sorted.cpp
@@ -55,12 +55,7 @@ bool EnsureSortedStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState EnsureSortedStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState EnsureSortedStage::doWork(WorkingSetID* out) {
StageState stageState = child()->work(out);
if (PlanStage::ADVANCED == stageState) {
@@ -76,22 +71,14 @@ PlanStage::StageState EnsureSortedStage::work(WorkingSetID* out) {
// 'member' is out of order. Drop it from the result set.
_ws->free(*out);
++_specificStats.nDropped;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
invariant(curSortKey.isOwned());
_prevSortKey = curSortKey;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
- if (PlanStage::NEED_TIME == stageState) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == stageState) {
- ++_commonStats.needYield;
- }
-
return stageState;
}
diff --git a/src/mongo/db/exec/ensure_sorted.h b/src/mongo/db/exec/ensure_sorted.h
index fe47e79e306..3a58f4767de 100644
--- a/src/mongo/db/exec/ensure_sorted.h
+++ b/src/mongo/db/exec/ensure_sorted.h
@@ -44,7 +44,7 @@ public:
EnsureSortedStage(OperationContext* opCtx, BSONObj pattern, WorkingSet* ws, PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_ENSURE_SORTED;
diff --git a/src/mongo/db/exec/eof.cpp b/src/mongo/db/exec/eof.cpp
index f5f127f016a..2f8f552bed2 100644
--- a/src/mongo/db/exec/eof.cpp
+++ b/src/mongo/db/exec/eof.cpp
@@ -50,10 +50,7 @@ bool EOFStage::isEOF() {
return true;
}
-PlanStage::StageState EOFStage::work(WorkingSetID* out) {
- ++_commonStats.works;
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
+PlanStage::StageState EOFStage::doWork(WorkingSetID* out) {
return PlanStage::IS_EOF;
}
diff --git a/src/mongo/db/exec/eof.h b/src/mongo/db/exec/eof.h
index 6796e4994e7..4d0caa76029 100644
--- a/src/mongo/db/exec/eof.h
+++ b/src/mongo/db/exec/eof.h
@@ -43,7 +43,7 @@ public:
~EOFStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp
index 4088d1d10b3..aaef747d95a 100644
--- a/src/mongo/db/exec/fetch.cpp
+++ b/src/mongo/db/exec/fetch.cpp
@@ -74,12 +74,7 @@ bool FetchStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState FetchStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState FetchStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -116,7 +111,6 @@ PlanStage::StageState FetchStage::work(WorkingSetID* out) {
_idRetrying = id;
member->setFetcher(fetcher.release());
*out = id;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -124,7 +118,6 @@ PlanStage::StageState FetchStage::work(WorkingSetID* out) {
// as well as an unowned object
if (!WorkingSetCommon::fetch(getOpCtx(), _ws, id, _cursor)) {
_ws->free(id);
- _commonStats.needTime++;
return NEED_TIME;
}
} catch (const WriteConflictException& wce) {
@@ -133,7 +126,6 @@ PlanStage::StageState FetchStage::work(WorkingSetID* out) {
member->makeObjOwnedIfNeeded();
_idRetrying = id;
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
}
@@ -151,10 +143,7 @@ PlanStage::StageState FetchStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
return status;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
*out = id;
}
@@ -214,13 +203,9 @@ PlanStage::StageState FetchStage::returnIfMatches(WorkingSetMember* member,
if (Filter::passes(member, _filter)) {
*out = memberID;
-
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else {
_ws->free(memberID);
-
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
diff --git a/src/mongo/db/exec/fetch.h b/src/mongo/db/exec/fetch.h
index 3aab5e6242b..f5fafd66786 100644
--- a/src/mongo/db/exec/fetch.h
+++ b/src/mongo/db/exec/fetch.h
@@ -58,7 +58,7 @@ public:
~FetchStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/group.cpp b/src/mongo/db/exec/group.cpp
index 4ce1d4031db..c03e7643f13 100644
--- a/src/mongo/db/exec/group.cpp
+++ b/src/mongo/db/exec/group.cpp
@@ -198,11 +198,7 @@ StatusWith<BSONObj> GroupStage::finalizeResults() {
return results;
}
-PlanStage::StageState GroupStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState GroupStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -215,7 +211,6 @@ PlanStage::StageState GroupStage::work(WorkingSetID* out) {
return PlanStage::FAILURE;
}
_groupState = GroupState_ReadingFromChild;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -225,10 +220,8 @@ PlanStage::StageState GroupStage::work(WorkingSetID* out) {
StageState state = child()->work(&id);
if (PlanStage::NEED_TIME == state) {
- ++_commonStats.needTime;
return state;
} else if (PlanStage::NEED_YIELD == state) {
- ++_commonStats.needYield;
*out = id;
return state;
} else if (PlanStage::FAILURE == state) {
@@ -257,7 +250,6 @@ PlanStage::StageState GroupStage::work(WorkingSetID* out) {
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else {
// We're done reading from our child.
@@ -277,7 +269,6 @@ PlanStage::StageState GroupStage::work(WorkingSetID* out) {
member->obj = Snapshotted<BSONObj>(SnapshotId(), results.getValue());
member->transitionToOwnedObj();
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
}
diff --git a/src/mongo/db/exec/group.h b/src/mongo/db/exec/group.h
index da89599ca3b..4199bc20cd5 100644
--- a/src/mongo/db/exec/group.h
+++ b/src/mongo/db/exec/group.h
@@ -87,7 +87,7 @@ public:
WorkingSet* workingSet,
PlanStage* child);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
StageType stageType() const final {
diff --git a/src/mongo/db/exec/idhack.cpp b/src/mongo/db/exec/idhack.cpp
index 90c3be244ae..b6cdcc530fa 100644
--- a/src/mongo/db/exec/idhack.cpp
+++ b/src/mongo/db/exec/idhack.cpp
@@ -101,12 +101,7 @@ bool IDHackStage::isEOF() {
return _done;
}
-PlanStage::StageState IDHackStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState IDHackStage::doWork(WorkingSetID* out) {
if (_done) {
return PlanStage::IS_EOF;
}
@@ -152,7 +147,6 @@ PlanStage::StageState IDHackStage::work(WorkingSetID* out) {
_idBeingPagedIn = id;
member->setFetcher(fetcher.release());
*out = id;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -174,7 +168,6 @@ PlanStage::StageState IDHackStage::work(WorkingSetID* out) {
_workingSet->free(id);
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
}
@@ -192,7 +185,6 @@ PlanStage::StageState IDHackStage::advance(WorkingSetID id,
}
_done = true;
- ++_commonStats.advanced;
*out = id;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/idhack.h b/src/mongo/db/exec/idhack.h
index 9eb143e4193..c989bf3cff7 100644
--- a/src/mongo/db/exec/idhack.h
+++ b/src/mongo/db/exec/idhack.h
@@ -62,7 +62,7 @@ public:
~IDHackStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/index_iterator.cpp b/src/mongo/db/exec/index_iterator.cpp
index f12947b996d..454731cc545 100644
--- a/src/mongo/db/exec/index_iterator.cpp
+++ b/src/mongo/db/exec/index_iterator.cpp
@@ -57,12 +57,7 @@ IndexIteratorStage::IndexIteratorStage(OperationContext* txn,
invariant(_collection); // It is illegal to use this stage without a collection.
}
-PlanStage::StageState IndexIteratorStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState IndexIteratorStage::doWork(WorkingSetID* out) {
if (auto entry = _cursor->next()) {
if (!entry->key.isOwned())
entry->key = entry->key.getOwned();
@@ -74,7 +69,6 @@ PlanStage::StageState IndexIteratorStage::work(WorkingSetID* out) {
_ws->transitionToLocAndIdx(id);
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/index_iterator.h b/src/mongo/db/exec/index_iterator.h
index 3adb1a33104..a39b36c6ca5 100644
--- a/src/mongo/db/exec/index_iterator.h
+++ b/src/mongo/db/exec/index_iterator.h
@@ -51,7 +51,7 @@ public:
BSONObj keyPattern,
std::unique_ptr<SortedDataInterface::Cursor> cursor);
- PlanStage::StageState work(WorkingSetID* out) final;
+ PlanStage::StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index b9d74b21099..62058fc8d8f 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -121,12 +121,7 @@ boost::optional<IndexKeyEntry> IndexScan::initIndexScan() {
}
}
-PlanStage::StageState IndexScan::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState IndexScan::doWork(WorkingSetID* out) {
// Get the next kv pair from the index, if any.
boost::optional<IndexKeyEntry> kv;
try {
@@ -176,7 +171,6 @@ PlanStage::StageState IndexScan::work(WorkingSetID* out) {
case IndexBoundsChecker::MUST_ADVANCE:
_scanState = NEED_SEEK;
- _commonStats.needTime++;
return PlanStage::NEED_TIME;
}
}
@@ -195,14 +189,12 @@ PlanStage::StageState IndexScan::work(WorkingSetID* out) {
if (!_returned.insert(kv->loc).second) {
// We've seen this RecordId before. Skip it this time.
++_specificStats.dupsDropped;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
if (_filter) {
if (!Filter::passes(kv->key, _keyPattern, _filter)) {
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
@@ -224,7 +216,6 @@ PlanStage::StageState IndexScan::work(WorkingSetID* out) {
}
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/index_scan.h b/src/mongo/db/exec/index_scan.h
index e3e80fc7071..c6f43992d47 100644
--- a/src/mongo/db/exec/index_scan.h
+++ b/src/mongo/db/exec/index_scan.h
@@ -95,7 +95,7 @@ public:
WorkingSet* workingSet,
const MatchExpression* filter);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/keep_mutations.cpp b/src/mongo/db/exec/keep_mutations.cpp
index f1d38d033c6..24c7f492e96 100644
--- a/src/mongo/db/exec/keep_mutations.cpp
+++ b/src/mongo/db/exec/keep_mutations.cpp
@@ -59,12 +59,7 @@ bool KeepMutationsStage::isEOF() {
return _doneReadingChild && _doneReturningFlagged;
}
-PlanStage::StageState KeepMutationsStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState KeepMutationsStage::doWork(WorkingSetID* out) {
// If we've returned as many results as we're limited to, isEOF will be true.
if (isEOF()) {
return PlanStage::IS_EOF;
@@ -76,14 +71,6 @@ PlanStage::StageState KeepMutationsStage::work(WorkingSetID* out) {
// Child is still returning results. Pass them through.
if (PlanStage::IS_EOF != status) {
- if (PlanStage::ADVANCED == status) {
- ++_commonStats.advanced;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
- }
-
return status;
}
@@ -112,11 +99,9 @@ PlanStage::StageState KeepMutationsStage::work(WorkingSetID* out) {
WorkingSetMember* member = _workingSet->get(idToTest);
if (Filter::passes(member, _filter)) {
*out = idToTest;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else {
_workingSet->free(idToTest);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
diff --git a/src/mongo/db/exec/keep_mutations.h b/src/mongo/db/exec/keep_mutations.h
index 878de151549..07883c5a7a9 100644
--- a/src/mongo/db/exec/keep_mutations.h
+++ b/src/mongo/db/exec/keep_mutations.h
@@ -53,7 +53,7 @@ public:
~KeepMutationsStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_KEEP_MUTATIONS;
diff --git a/src/mongo/db/exec/limit.cpp b/src/mongo/db/exec/limit.cpp
index c595a455f25..4472f41f2ba 100644
--- a/src/mongo/db/exec/limit.cpp
+++ b/src/mongo/db/exec/limit.cpp
@@ -54,12 +54,7 @@ bool LimitStage::isEOF() {
return (0 == _numToReturn) || child()->isEOF();
}
-PlanStage::StageState LimitStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState LimitStage::doWork(WorkingSetID* out) {
if (0 == _numToReturn) {
// We've returned as many results as we're limited to.
return PlanStage::IS_EOF;
@@ -71,7 +66,6 @@ PlanStage::StageState LimitStage::work(WorkingSetID* out) {
if (PlanStage::ADVANCED == status) {
*out = id;
--_numToReturn;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) {
*out = id;
@@ -85,10 +79,7 @@ PlanStage::StageState LimitStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
return status;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
*out = id;
}
diff --git a/src/mongo/db/exec/limit.h b/src/mongo/db/exec/limit.h
index f51061d6049..b5e2e690b80 100644
--- a/src/mongo/db/exec/limit.h
+++ b/src/mongo/db/exec/limit.h
@@ -48,7 +48,7 @@ public:
~LimitStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_LIMIT;
diff --git a/src/mongo/db/exec/merge_sort.cpp b/src/mongo/db/exec/merge_sort.cpp
index 10c85b68304..4aa2bb8c62c 100644
--- a/src/mongo/db/exec/merge_sort.cpp
+++ b/src/mongo/db/exec/merge_sort.cpp
@@ -69,12 +69,7 @@ bool MergeSortStage::isEOF() {
return _merging.empty() && _noResultToMerge.empty();
}
-PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState MergeSortStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -101,7 +96,6 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
if (_seen.end() != _seen.find(member->loc)) {
// ...drop it.
_ws->free(id);
- ++_commonStats.needTime;
++_specificStats.dupsDropped;
return PlanStage::NEED_TIME;
} else {
@@ -129,13 +123,11 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
// Insert the result (indirectly) into our priority queue.
_merging.push(_mergingData.begin());
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == code) {
// There are no more results possible from this child. Don't bother with it
// anymore.
_noResultToMerge.pop();
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::FAILURE == code || PlanStage::DEAD == code) {
*out = id;
@@ -150,11 +142,8 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
}
return code;
} else {
- if (PlanStage::NEED_TIME == code) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == code) {
+ if (PlanStage::NEED_YIELD == code) {
*out = id;
- ++_commonStats.needYield;
}
return code;
@@ -178,7 +167,6 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
// Return the min.
*out = idToTest;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/merge_sort.h b/src/mongo/db/exec/merge_sort.h
index f95eb8f9a71..611dcba48fe 100644
--- a/src/mongo/db/exec/merge_sort.h
+++ b/src/mongo/db/exec/merge_sort.h
@@ -63,7 +63,7 @@ public:
void addChild(PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/multi_iterator.cpp b/src/mongo/db/exec/multi_iterator.cpp
index ffa3ece0b4e..cd9d0954538 100644
--- a/src/mongo/db/exec/multi_iterator.cpp
+++ b/src/mongo/db/exec/multi_iterator.cpp
@@ -55,7 +55,7 @@ void MultiIteratorStage::addIterator(unique_ptr<RecordCursor> it) {
_iterators.push_back(std::move(it));
}
-PlanStage::StageState MultiIteratorStage::work(WorkingSetID* out) {
+PlanStage::StageState MultiIteratorStage::doWork(WorkingSetID* out) {
if (_collection == NULL) {
Status status(ErrorCodes::InternalError, "MultiIteratorStage died on null collection");
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
diff --git a/src/mongo/db/exec/multi_iterator.h b/src/mongo/db/exec/multi_iterator.h
index 8c260e2042b..ec9ff88c11b 100644
--- a/src/mongo/db/exec/multi_iterator.h
+++ b/src/mongo/db/exec/multi_iterator.h
@@ -51,7 +51,7 @@ public:
void addIterator(std::unique_ptr<RecordCursor> it);
- PlanStage::StageState work(WorkingSetID* out) final;
+ PlanStage::StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp
index 2eba6aede7a..bd0cf272188 100644
--- a/src/mongo/db/exec/multi_plan.cpp
+++ b/src/mongo/db/exec/multi_plan.cpp
@@ -98,10 +98,7 @@ bool MultiPlanStage::isEOF() {
return bestPlan.results.empty() && bestPlan.root->isEOF();
}
-PlanStage::StageState MultiPlanStage::work(WorkingSetID* out) {
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState MultiPlanStage::doWork(WorkingSetID* out) {
if (_failure) {
*out = _statusMemberId;
return PlanStage::FAILURE;
@@ -113,7 +110,6 @@ PlanStage::StageState MultiPlanStage::work(WorkingSetID* out) {
if (!bestPlan.results.empty()) {
*out = bestPlan.results.front();
bestPlan.results.pop_front();
- _commonStats.advanced++;
return PlanStage::ADVANCED;
}
@@ -144,15 +140,6 @@ PlanStage::StageState MultiPlanStage::work(WorkingSetID* out) {
_backupPlanIdx = kNoSuchPlan;
}
- // Increment stats.
- if (PlanStage::ADVANCED == state) {
- _commonStats.advanced++;
- } else if (PlanStage::NEED_TIME == state) {
- _commonStats.needTime++;
- } else if (PlanStage::NEED_YIELD == state) {
- _commonStats.needYield++;
- }
-
return state;
}
diff --git a/src/mongo/db/exec/multi_plan.h b/src/mongo/db/exec/multi_plan.h
index 0a9818b85cd..3aff4852c19 100644
--- a/src/mongo/db/exec/multi_plan.h
+++ b/src/mongo/db/exec/multi_plan.h
@@ -82,7 +82,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/near.cpp b/src/mongo/db/exec/near.cpp
index 3a25432c2b9..1eedc41c1ba 100644
--- a/src/mongo/db/exec/near.cpp
+++ b/src/mongo/db/exec/near.cpp
@@ -81,12 +81,7 @@ PlanStage::StageState NearStage::initNext(WorkingSetID* out) {
return state;
}
-PlanStage::StageState NearStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState NearStage::doWork(WorkingSetID* out) {
WorkingSetID toReturn = WorkingSet::INVALID_ID;
Status error = Status::OK();
PlanStage::StageState nextState = PlanStage::NEED_TIME;
@@ -114,12 +109,8 @@ PlanStage::StageState NearStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_workingSet, error);
} else if (PlanStage::ADVANCED == nextState) {
*out = toReturn;
- ++_commonStats.advanced;
} else if (PlanStage::NEED_YIELD == nextState) {
*out = toReturn;
- ++_commonStats.needYield;
- } else if (PlanStage::NEED_TIME == nextState) {
- ++_commonStats.needTime;
} else if (PlanStage::IS_EOF == nextState) {
_commonStats.isEOF = true;
}
diff --git a/src/mongo/db/exec/near.h b/src/mongo/db/exec/near.h
index abc8f0d35e9..e2eba0c6b53 100644
--- a/src/mongo/db/exec/near.h
+++ b/src/mongo/db/exec/near.h
@@ -98,7 +98,7 @@ public:
~NearStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/oplogstart.cpp b/src/mongo/db/exec/oplogstart.cpp
index 3bf2c17fe5b..5041d3af4f9 100644
--- a/src/mongo/db/exec/oplogstart.cpp
+++ b/src/mongo/db/exec/oplogstart.cpp
@@ -56,7 +56,7 @@ OplogStart::OplogStart(OperationContext* txn,
_workingSet(ws),
_filter(filter) {}
-PlanStage::StageState OplogStart::work(WorkingSetID* out) {
+PlanStage::StageState OplogStart::doWork(WorkingSetID* out) {
// We do our (heavy) init in a work(), where work is expected.
if (_needInit) {
CollectionScanParams params;
diff --git a/src/mongo/db/exec/oplogstart.h b/src/mongo/db/exec/oplogstart.h
index 8825d1a5d54..4fd5df13eb8 100644
--- a/src/mongo/db/exec/oplogstart.h
+++ b/src/mongo/db/exec/oplogstart.h
@@ -68,7 +68,7 @@ public:
MatchExpression* filter,
WorkingSet* ws);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/or.cpp b/src/mongo/db/exec/or.cpp
index dae040ff9b5..718e59b50ba 100644
--- a/src/mongo/db/exec/or.cpp
+++ b/src/mongo/db/exec/or.cpp
@@ -54,12 +54,7 @@ bool OrStage::isEOF() {
return _currentChild >= _children.size();
}
-PlanStage::StageState OrStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState OrStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -79,7 +74,6 @@ PlanStage::StageState OrStage::work(WorkingSetID* out) {
// ...drop it.
++_specificStats.dupsDropped;
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else {
// Otherwise, note that we've seen it.
@@ -90,12 +84,10 @@ PlanStage::StageState OrStage::work(WorkingSetID* out) {
if (Filter::passes(member, _filter)) {
// Match! return it.
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else {
// Does not match, try again.
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
} else if (PlanStage::IS_EOF == childStatus) {
@@ -106,7 +98,6 @@ PlanStage::StageState OrStage::work(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
} else {
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
} else if (PlanStage::FAILURE == childStatus || PlanStage::DEAD == childStatus) {
@@ -121,10 +112,7 @@ PlanStage::StageState OrStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
return childStatus;
- } else if (PlanStage::NEED_TIME == childStatus) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == childStatus) {
- ++_commonStats.needYield;
*out = id;
}
diff --git a/src/mongo/db/exec/or.h b/src/mongo/db/exec/or.h
index ebe9d7bc10c..ea056d7db91 100644
--- a/src/mongo/db/exec/or.h
+++ b/src/mongo/db/exec/or.h
@@ -51,7 +51,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/pipeline_proxy.cpp b/src/mongo/db/exec/pipeline_proxy.cpp
index 6011c3acc0f..b2e987e1435 100644
--- a/src/mongo/db/exec/pipeline_proxy.cpp
+++ b/src/mongo/db/exec/pipeline_proxy.cpp
@@ -55,7 +55,7 @@ PipelineProxyStage::PipelineProxyStage(OperationContext* opCtx,
_childExec(child),
_ws(ws) {}
-PlanStage::StageState PipelineProxyStage::work(WorkingSetID* out) {
+PlanStage::StageState PipelineProxyStage::doWork(WorkingSetID* out) {
if (!out) {
return PlanStage::FAILURE;
}
diff --git a/src/mongo/db/exec/pipeline_proxy.h b/src/mongo/db/exec/pipeline_proxy.h
index a82c5fe13fb..791a1ebfa62 100644
--- a/src/mongo/db/exec/pipeline_proxy.h
+++ b/src/mongo/db/exec/pipeline_proxy.h
@@ -49,7 +49,7 @@ public:
const std::shared_ptr<PlanExecutor>& child,
WorkingSet* ws);
- PlanStage::StageState work(WorkingSetID* out) final;
+ PlanStage::StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
diff --git a/src/mongo/db/exec/plan_stage.cpp b/src/mongo/db/exec/plan_stage.cpp
index 95fe9b0ed95..c81679bd8cb 100644
--- a/src/mongo/db/exec/plan_stage.cpp
+++ b/src/mongo/db/exec/plan_stage.cpp
@@ -32,8 +32,27 @@
#include "mongo/db/exec/plan_stage.h"
+#include "mongo/db/exec/scoped_timer.h"
+
namespace mongo {
+PlanStage::StageState PlanStage::work(WorkingSetID* out) {
+ ScopedTimer timer(&_commonStats.executionTimeMillis);
+ ++_commonStats.works;
+
+ StageState workResult = doWork(out);
+
+ if (StageState::ADVANCED == workResult) {
+ ++_commonStats.advanced;
+ } else if (StageState::NEED_TIME == workResult) {
+ ++_commonStats.needTime;
+ } else if (StageState::NEED_YIELD == workResult) {
+ ++_commonStats.needYield;
+ }
+
+ return workResult;
+}
+
void PlanStage::saveState() {
++_commonStats.yields;
for (auto&& child : _children) {
diff --git a/src/mongo/db/exec/plan_stage.h b/src/mongo/db/exec/plan_stage.h
index feefd5c2de9..3ad007c8430 100644
--- a/src/mongo/db/exec/plan_stage.h
+++ b/src/mongo/db/exec/plan_stage.h
@@ -185,7 +185,7 @@ public:
* Stage returns StageState::ADVANCED if *out is set to the next unit of output. Otherwise,
* returns another value of StageState to indicate the stage's status.
*/
- virtual StageState work(WorkingSetID* out) = 0;
+ StageState work(WorkingSetID* out);
/**
* Returns true if no more work can be done on the query / out of results.
@@ -319,6 +319,11 @@ public:
protected:
/**
+ * Performs one unit of work. See comment at work() above.
+ */
+ virtual StageState doWork(WorkingSetID* out) = 0;
+
+ /**
* Saves any stage-specific state required to resume where it was if the underlying data
* changes.
*
diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp
index 95f5a7112f3..bc066c96d8a 100644
--- a/src/mongo/db/exec/projection.cpp
+++ b/src/mongo/db/exec/projection.cpp
@@ -192,12 +192,7 @@ bool ProjectionStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState ProjectionStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState ProjectionStage::doWork(WorkingSetID* out) {
WorkingSetID id = WorkingSet::INVALID_ID;
StageState status = child()->work(&id);
@@ -214,7 +209,6 @@ PlanStage::StageState ProjectionStage::work(WorkingSetID* out) {
}
*out = id;
- ++_commonStats.advanced;
} else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) {
*out = id;
// If a stage fails, it may create a status WSM to indicate why it
@@ -226,10 +220,7 @@ PlanStage::StageState ProjectionStage::work(WorkingSetID* out) {
Status status(ErrorCodes::InternalError, ss);
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
- } else if (PlanStage::NEED_TIME == status) {
- _commonStats.needTime++;
} else if (PlanStage::NEED_YIELD == status) {
- _commonStats.needYield++;
*out = id;
}
diff --git a/src/mongo/db/exec/projection.h b/src/mongo/db/exec/projection.h
index aa03665bd3a..4d512fe1c6f 100644
--- a/src/mongo/db/exec/projection.h
+++ b/src/mongo/db/exec/projection.h
@@ -83,7 +83,7 @@ public:
PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_PROJECTION;
diff --git a/src/mongo/db/exec/queued_data_stage.cpp b/src/mongo/db/exec/queued_data_stage.cpp
index 9ea015f9c62..6f3f3b0ed2f 100644
--- a/src/mongo/db/exec/queued_data_stage.cpp
+++ b/src/mongo/db/exec/queued_data_stage.cpp
@@ -43,12 +43,7 @@ const char* QueuedDataStage::kStageType = "QUEUED_DATA";
QueuedDataStage::QueuedDataStage(OperationContext* opCtx, WorkingSet* ws)
: PlanStage(kStageType, opCtx), _ws(ws) {}
-PlanStage::StageState QueuedDataStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState QueuedDataStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -57,11 +52,8 @@ PlanStage::StageState QueuedDataStage::work(WorkingSetID* out) {
_results.pop();
if (PlanStage::ADVANCED == state) {
- ++_commonStats.advanced;
*out = _members.front();
_members.pop();
- } else if (PlanStage::NEED_TIME == state) {
- ++_commonStats.needTime;
}
return state;
diff --git a/src/mongo/db/exec/queued_data_stage.h b/src/mongo/db/exec/queued_data_stage.h
index 7e44bc7f3d5..2e179b188b1 100644
--- a/src/mongo/db/exec/queued_data_stage.h
+++ b/src/mongo/db/exec/queued_data_stage.h
@@ -49,7 +49,7 @@ class QueuedDataStage final : public PlanStage {
public:
QueuedDataStage(OperationContext* opCtx, WorkingSet* ws);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
diff --git a/src/mongo/db/exec/shard_filter.cpp b/src/mongo/db/exec/shard_filter.cpp
index 021e5c09c8b..8388689cbc6 100644
--- a/src/mongo/db/exec/shard_filter.cpp
+++ b/src/mongo/db/exec/shard_filter.cpp
@@ -64,12 +64,7 @@ bool ShardFilterStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState ShardFilterStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState ShardFilterStage::doWork(WorkingSetID* out) {
// If we've returned as many results as we're limited to, isEOF will be true.
if (isEOF()) {
return PlanStage::IS_EOF;
@@ -121,12 +116,7 @@ PlanStage::StageState ShardFilterStage::work(WorkingSetID* out) {
// If we're here either we have shard state and our doc passed, or we have no shard
// state. Either way, we advance.
- ++_commonStats.advanced;
return status;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
}
return status;
diff --git a/src/mongo/db/exec/shard_filter.h b/src/mongo/db/exec/shard_filter.h
index 88a86c3577a..44d7bc08055 100644
--- a/src/mongo/db/exec/shard_filter.h
+++ b/src/mongo/db/exec/shard_filter.h
@@ -78,7 +78,7 @@ public:
~ShardFilterStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_SHARDING_FILTER;
diff --git a/src/mongo/db/exec/skip.cpp b/src/mongo/db/exec/skip.cpp
index 5c5a27a685f..7a353e5219f 100644
--- a/src/mongo/db/exec/skip.cpp
+++ b/src/mongo/db/exec/skip.cpp
@@ -52,12 +52,7 @@ bool SkipStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState SkipStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState SkipStage::doWork(WorkingSetID* out) {
WorkingSetID id = WorkingSet::INVALID_ID;
StageState status = child()->work(&id);
@@ -67,12 +62,10 @@ PlanStage::StageState SkipStage::work(WorkingSetID* out) {
// ...drop the result.
--_toSkip;
_ws->free(id);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
} else if (PlanStage::FAILURE == status || PlanStage::DEAD == status) {
*out = id;
@@ -86,10 +79,7 @@ PlanStage::StageState SkipStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
return status;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
*out = id;
}
diff --git a/src/mongo/db/exec/skip.h b/src/mongo/db/exec/skip.h
index e97a75b9b64..335347b66a0 100644
--- a/src/mongo/db/exec/skip.h
+++ b/src/mongo/db/exec/skip.h
@@ -47,7 +47,7 @@ public:
~SkipStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_SKIP;
diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp
index b7b6fc0fc86..a621fbe945e 100644
--- a/src/mongo/db/exec/sort.cpp
+++ b/src/mongo/db/exec/sort.cpp
@@ -101,12 +101,7 @@ bool SortStage::isEOF() {
return child()->isEOF() && _sorted && (_data.end() == _resultIterator);
}
-PlanStage::StageState SortStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState SortStage::doWork(WorkingSetID* out) {
const size_t maxBytes = static_cast<size_t>(internalQueryExecMaxBlockingSortBytes);
if (_memUsage > maxBytes) {
mongoutils::str::stream ss;
@@ -156,7 +151,6 @@ PlanStage::StageState SortStage::work(WorkingSetID* out) {
addToBuffer(item);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == code) {
// TODO: We don't need the lock for this. We could ask for a yield and do this work
@@ -164,7 +158,6 @@ PlanStage::StageState SortStage::work(WorkingSetID* out) {
sortBuffer();
_resultIterator = _data.begin();
_sorted = true;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::FAILURE == code || PlanStage::DEAD == code) {
*out = id;
@@ -178,10 +171,7 @@ PlanStage::StageState SortStage::work(WorkingSetID* out) {
*out = WorkingSetCommon::allocateStatusMember(_ws, status);
}
return code;
- } else if (PlanStage::NEED_TIME == code) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == code) {
- ++_commonStats.needYield;
*out = id;
}
@@ -201,7 +191,6 @@ PlanStage::StageState SortStage::work(WorkingSetID* out) {
_wsidByDiskLoc.erase(member->loc);
}
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
diff --git a/src/mongo/db/exec/sort.h b/src/mongo/db/exec/sort.h
index e9d75186f2a..aab0d3e6a8d 100644
--- a/src/mongo/db/exec/sort.h
+++ b/src/mongo/db/exec/sort.h
@@ -75,7 +75,7 @@ public:
~SortStage();
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doInvalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) final;
diff --git a/src/mongo/db/exec/sort_key_generator.cpp b/src/mongo/db/exec/sort_key_generator.cpp
index 26e9d6886db..22237b02353 100644
--- a/src/mongo/db/exec/sort_key_generator.cpp
+++ b/src/mongo/db/exec/sort_key_generator.cpp
@@ -281,15 +281,9 @@ bool SortKeyGeneratorStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState SortKeyGeneratorStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState SortKeyGeneratorStage::doWork(WorkingSetID* out) {
if (!_sortKeyGen) {
_sortKeyGen = stdx::make_unique<SortKeyGenerator>(_sortSpec, _query);
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -312,10 +306,6 @@ PlanStage::StageState SortKeyGeneratorStage::work(WorkingSetID* out) {
if (stageState == PlanStage::IS_EOF) {
_commonStats.isEOF = true;
- } else if (stageState == PlanStage::NEED_TIME) {
- ++_commonStats.needTime;
- } else if (stageState == PlanStage::NEED_YIELD) {
- ++_commonStats.needYield;
}
return stageState;
diff --git a/src/mongo/db/exec/sort_key_generator.h b/src/mongo/db/exec/sort_key_generator.h
index 555d6b8ce6b..ea035c5db5e 100644
--- a/src/mongo/db/exec/sort_key_generator.h
+++ b/src/mongo/db/exec/sort_key_generator.h
@@ -114,7 +114,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_SORT_KEY_GENERATOR;
diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp
index df514861011..6ee273034d4 100644
--- a/src/mongo/db/exec/subplan.cpp
+++ b/src/mongo/db/exec/subplan.cpp
@@ -511,28 +511,13 @@ bool SubplanStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState SubplanStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState SubplanStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
invariant(child());
- StageState state = child()->work(out);
-
- if (PlanStage::NEED_TIME == state) {
- ++_commonStats.needTime;
- } else if (PlanStage::NEED_YIELD == state) {
- ++_commonStats.needYield;
- } else if (PlanStage::ADVANCED == state) {
- ++_commonStats.advanced;
- }
-
- return state;
+ return child()->work(out);
}
unique_ptr<PlanStageStats> SubplanStage::getStats() {
diff --git a/src/mongo/db/exec/subplan.h b/src/mongo/db/exec/subplan.h
index bbb401d337a..5c0859ba8fe 100644
--- a/src/mongo/db/exec/subplan.h
+++ b/src/mongo/db/exec/subplan.h
@@ -75,7 +75,7 @@ public:
static bool canUseSubplanning(const CanonicalQuery& query);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_SUBPLAN;
diff --git a/src/mongo/db/exec/text.cpp b/src/mongo/db/exec/text.cpp
index 424b372b017..295baa10b14 100644
--- a/src/mongo/db/exec/text.cpp
+++ b/src/mongo/db/exec/text.cpp
@@ -70,34 +70,12 @@ bool TextStage::isEOF() {
return child()->isEOF();
}
-PlanStage::StageState TextStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState TextStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
- PlanStage::StageState stageState = child()->work(out);
-
- // Increment common stats counters that are specific to the return value of work().
- switch (stageState) {
- case PlanStage::ADVANCED:
- ++_commonStats.advanced;
- break;
- case PlanStage::NEED_TIME:
- ++_commonStats.needTime;
- break;
- case PlanStage::NEED_YIELD:
- ++_commonStats.needYield;
- break;
- default:
- break;
- }
-
- return stageState;
+ return child()->work(out);
}
unique_ptr<PlanStageStats> TextStage::getStats() {
diff --git a/src/mongo/db/exec/text.h b/src/mongo/db/exec/text.h
index a79634c0fb7..6335c1cf2d7 100644
--- a/src/mongo/db/exec/text.h
+++ b/src/mongo/db/exec/text.h
@@ -77,7 +77,7 @@ public:
const MatchExpression* filter);
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
bool isEOF() final;
StageType stageType() const final {
diff --git a/src/mongo/db/exec/text_match.cpp b/src/mongo/db/exec/text_match.cpp
index 37d199011bd..0d94a8a5bfb 100644
--- a/src/mongo/db/exec/text_match.cpp
+++ b/src/mongo/db/exec/text_match.cpp
@@ -74,12 +74,7 @@ const SpecificStats* TextMatchStage::getSpecificStats() const {
return &_specificStats;
}
-PlanStage::StageState TextMatchStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState TextMatchStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -110,21 +105,6 @@ PlanStage::StageState TextMatchStage::work(WorkingSetID* out) {
}
}
- // Increment common stats counters that are specific to the return value of work().
- switch (stageState) {
- case PlanStage::ADVANCED:
- ++_commonStats.advanced;
- break;
- case PlanStage::NEED_TIME:
- ++_commonStats.needTime;
- break;
- case PlanStage::NEED_YIELD:
- ++_commonStats.needYield;
- break;
- default:
- break;
- }
-
return stageState;
}
diff --git a/src/mongo/db/exec/text_match.h b/src/mongo/db/exec/text_match.h
index be1e6a2dd79..8fff04e4d54 100644
--- a/src/mongo/db/exec/text_match.h
+++ b/src/mongo/db/exec/text_match.h
@@ -68,7 +68,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
StageType stageType() const final {
return STAGE_TEXT_MATCH;
diff --git a/src/mongo/db/exec/text_or.cpp b/src/mongo/db/exec/text_or.cpp
index 66ac3c51953..e09c52e08bd 100644
--- a/src/mongo/db/exec/text_or.cpp
+++ b/src/mongo/db/exec/text_or.cpp
@@ -133,12 +133,7 @@ const SpecificStats* TextOrStage::getSpecificStats() const {
return &_specificStats;
}
-PlanStage::StageState TextOrStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState TextOrStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -161,21 +156,6 @@ PlanStage::StageState TextOrStage::work(WorkingSetID* out) {
break;
}
- // Increment common stats counters.
- switch (stageState) {
- case PlanStage::ADVANCED:
- ++_commonStats.advanced;
- break;
- case PlanStage::NEED_TIME:
- ++_commonStats.needTime;
- break;
- case PlanStage::NEED_YIELD:
- ++_commonStats.needYield;
- break;
- default:
- break;
- }
-
return stageState;
}
diff --git a/src/mongo/db/exec/text_or.h b/src/mongo/db/exec/text_or.h
index ade42440cc1..f977d11645e 100644
--- a/src/mongo/db/exec/text_or.h
+++ b/src/mongo/db/exec/text_or.h
@@ -83,7 +83,7 @@ public:
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doSaveState() final;
void doRestoreState() final;
diff --git a/src/mongo/db/exec/update.cpp b/src/mongo/db/exec/update.cpp
index bb2a7b83d82..895d9d0ce0c 100644
--- a/src/mongo/db/exec/update.cpp
+++ b/src/mongo/db/exec/update.cpp
@@ -728,12 +728,7 @@ bool UpdateStage::isEOF() {
return doneUpdating() && !needInsert();
}
-PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
- ++_commonStats.works;
-
- // Adds the amount of time taken by work() to executionTimeMillis.
- ScopedTimer timer(&_commonStats.executionTimeMillis);
-
+PlanStage::StageState UpdateStage::doWork(WorkingSetID* out) {
if (isEOF()) {
return PlanStage::IS_EOF;
}
@@ -758,7 +753,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
member->obj = Snapshotted<BSONObj>(getOpCtx()->recoveryUnit()->getSnapshotId(),
newObj.getOwned());
member->transitionToOwnedObj();
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
}
@@ -785,7 +779,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
*out = _idReturning;
_idReturning = WorkingSet::INVALID_ID;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
@@ -823,7 +816,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
}
++_specificStats.nInvalidateSkips;
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
loc = member->loc;
@@ -837,7 +829,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
// Found a loc that refers to a document we had already updated. Note that
// we can never remove from _updatedLocs because updates by other clients
// could cause us to encounter a document again later.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -848,7 +839,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
// our snapshot has changed, refetch
if (!WorkingSetCommon::fetch(getOpCtx(), _ws, id, cursor)) {
// document was deleted, we're done here
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
@@ -856,7 +846,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
CanonicalQuery* cq = _params.canonicalQuery;
if (cq && !cq->root()->matchesBSON(member->obj.value(), NULL)) {
// doesn't match predicates anymore!
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
}
}
@@ -910,7 +899,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
_idRetrying = id;
memberFreer.Dismiss(); // Keep this member around so we can retry updating it.
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -936,7 +924,6 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
memberFreer.Dismiss();
}
*out = WorkingSet::INVALID_ID;
- _commonStats.needYield++;
return NEED_YIELD;
}
@@ -946,16 +933,13 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
memberFreer.Dismiss(); // Keep this member around so we can return it.
*out = id;
- ++_commonStats.advanced;
return PlanStage::ADVANCED;
}
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::IS_EOF == status) {
// The child is out of results, but we might not be done yet because we still might
// have to do an insert.
- ++_commonStats.needTime;
return PlanStage::NEED_TIME;
} else if (PlanStage::FAILURE == status) {
*out = id;
@@ -968,10 +952,7 @@ PlanStage::StageState UpdateStage::work(WorkingSetID* out) {
return PlanStage::FAILURE;
}
return status;
- } else if (PlanStage::NEED_TIME == status) {
- ++_commonStats.needTime;
} else if (PlanStage::NEED_YIELD == status) {
- ++_commonStats.needYield;
*out = id;
}
diff --git a/src/mongo/db/exec/update.h b/src/mongo/db/exec/update.h
index 8cffbfcf408..235a234fb51 100644
--- a/src/mongo/db/exec/update.h
+++ b/src/mongo/db/exec/update.h
@@ -83,7 +83,7 @@ public:
PlanStage* child);
bool isEOF() final;
- StageState work(WorkingSetID* out) final;
+ StageState doWork(WorkingSetID* out) final;
void doRestoreState() final;