summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2018-05-31 14:09:31 -0400
committerEric Milkie <milkie@10gen.com>2018-06-04 09:34:40 -0400
commite15bbb6e877396f9963bc1fbb8c125b22f74216a (patch)
tree984951995d291b5ce7b59cb9036bfc6f1529a14b
parent6f487dbf613791084398d23656e40328ddde79e7 (diff)
downloadmongo-e15bbb6e877396f9963bc1fbb8c125b22f74216a.tar.gz
SERVER-35318 improve free monitoring op observer perf
(cherry picked from commit 13dfc0893e81926f7b54aae9a697f06ed78ee8dc)
-rw-r--r--src/mongo/db/free_mon/free_mon_op_observer.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/mongo/db/free_mon/free_mon_op_observer.cpp b/src/mongo/db/free_mon/free_mon_op_observer.cpp
index 2092a7274c3..b3457a687a6 100644
--- a/src/mongo/db/free_mon/free_mon_op_observer.cpp
+++ b/src/mongo/db/free_mon/free_mon_op_observer.cpp
@@ -70,6 +70,10 @@ void FreeMonOpObserver::onInserts(OperationContext* opCtx,
std::vector<InsertStatement>::const_iterator begin,
std::vector<InsertStatement>::const_iterator end,
bool fromMigrate) {
+ if (nss != NamespaceString::kServerConfigurationNamespace) {
+ return;
+ }
+
if (isStandaloneOrPrimary(opCtx)) {
return;
}
@@ -77,14 +81,12 @@ void FreeMonOpObserver::onInserts(OperationContext* opCtx,
for (auto it = begin; it != end; ++it) {
const auto& insertedDoc = it->doc;
- if (nss == NamespaceString::kServerConfigurationNamespace) {
- if (auto idElem = insertedDoc["_id"]) {
- if (idElem.str() == FreeMonStorage::kFreeMonDocIdKey) {
- auto controller = FreeMonController::get(opCtx->getServiceContext());
+ if (auto idElem = insertedDoc["_id"]) {
+ if (idElem.str() == FreeMonStorage::kFreeMonDocIdKey) {
+ auto controller = FreeMonController::get(opCtx->getServiceContext());
- if (controller != nullptr) {
- controller->notifyOnUpsert(insertedDoc.getOwned());
- }
+ if (controller != nullptr) {
+ controller->notifyOnUpsert(insertedDoc.getOwned());
}
}
}
@@ -92,17 +94,19 @@ void FreeMonOpObserver::onInserts(OperationContext* opCtx,
}
void FreeMonOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArgs& args) {
+ if (args.nss != NamespaceString::kServerConfigurationNamespace) {
+ return;
+ }
+
if (isStandaloneOrPrimary(opCtx)) {
return;
}
- if (args.nss == NamespaceString::kServerConfigurationNamespace) {
- if (args.updatedDoc["_id"].str() == FreeMonStorage::kFreeMonDocIdKey) {
- auto controller = FreeMonController::get(opCtx->getServiceContext());
+ if (args.updatedDoc["_id"].str() == FreeMonStorage::kFreeMonDocIdKey) {
+ auto controller = FreeMonController::get(opCtx->getServiceContext());
- if (controller != nullptr) {
- controller->notifyOnUpsert(args.updatedDoc.getOwned());
- }
+ if (controller != nullptr) {
+ controller->notifyOnUpsert(args.updatedDoc.getOwned());
}
}
}
@@ -113,17 +117,19 @@ void FreeMonOpObserver::onDelete(OperationContext* opCtx,
StmtId stmtId,
bool fromMigrate,
const boost::optional<BSONObj>& deletedDoc) {
+ if (nss != NamespaceString::kServerConfigurationNamespace) {
+ return;
+ }
+
if (isStandaloneOrPrimary(opCtx)) {
return;
}
- if (nss == NamespaceString::kServerConfigurationNamespace) {
- if (deletedDoc.get()["_id"].str() == FreeMonStorage::kFreeMonDocIdKey) {
- auto controller = FreeMonController::get(opCtx->getServiceContext());
+ if (deletedDoc.get()["_id"].str() == FreeMonStorage::kFreeMonDocIdKey) {
+ auto controller = FreeMonController::get(opCtx->getServiceContext());
- if (controller != nullptr) {
- controller->notifyOnDelete();
- }
+ if (controller != nullptr) {
+ controller->notifyOnDelete();
}
}
}