summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-29 13:50:42 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-06-05 14:21:56 -0400
commitf4ca1b7eb3850719049d938b4b4562b6324ec284 (patch)
treeee6b74b1321a5f8ee622bad55e9d959442d9e6e5
parent51c2064d518140fbeae62f9d7ba29f1d69fb530f (diff)
downloadmongo-f4ca1b7eb3850719049d938b4b4562b6324ec284.tar.gz
SERVER-18277 Get references to the Top object out of CurOp.
-rw-r--r--src/mongo/db/SConscript1
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp8
-rw-r--r--src/mongo/db/curop.cpp7
-rw-r--r--src/mongo/db/curop.h7
-rw-r--r--src/mongo/db/db_raii.cpp17
5 files changed, 27 insertions, 13 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index c46484860d7..249f88ee574 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -141,7 +141,6 @@ env.Library(
'$BUILD_DIR/mongo/bson/mutable/mutable_bson',
'$BUILD_DIR/mongo/db/commands/server_status_core',
'$BUILD_DIR/mongo/db/concurrency/lock_manager',
- '$BUILD_DIR/mongo/db/stats/top',
'$BUILD_DIR/mongo/util/fail_point',
'$BUILD_DIR/mongo/util/net/network',
'$BUILD_DIR/mongo/db/service_context',
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 0469027060b..acc7b27df62 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -67,6 +67,7 @@
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/db/stats/counters.h"
+#include "mongo/db/stats/top.h"
#include "mongo/db/write_concern.h"
#include "mongo/s/collection_metadata.h"
#include "mongo/s/d_state.h"
@@ -589,7 +590,12 @@ namespace mongo {
currentOp->done();
int executionTime = currentOp->debug().executionTime = currentOp->totalTimeMillis();
currentOp->debug().recordStats();
- currentOp->recordGlobalTime(true, currentOp->totalTimeMicros());
+ Top::get(txn->getClient()->getServiceContext()).record(
+ currentOp->getNS(),
+ currentOp->getOp(),
+ 1, // "write locked"
+ currentOp->totalTimeMicros(),
+ currentOp->isCommand());
if ( opError ) {
currentOp->debug().exceptionInfo = ExceptionInfo( opError->getErrMessage(),
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index a23011d6ae9..2998492b145 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -39,8 +39,6 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/json.h"
-#include "mongo/db/service_context.h"
-#include "mongo/db/stats/top.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
@@ -225,11 +223,6 @@ namespace mongo {
_dbprofile = std::max(dbProfileLevel, _dbprofile);
}
- void CurOp::recordGlobalTime(bool isWriteLocked, long long micros) const {
- int lockType = isWriteLocked ? 1 : -1;
- Top::get(getGlobalServiceContext()).record(_ns, _op, lockType, micros, _isCommand);
- }
-
void CurOp::reportState(BSONObjBuilder* builder) {
if (_start) {
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 19a307b2288..2067f1d7af5 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -269,6 +269,11 @@ namespace mongo {
*/
int getOp() const { return _op; }
+ /**
+ * Returns true if the current operation is known to be a command.
+ */
+ bool isCommand() const { return _isCommand; }
+
//
// Methods for controlling CurOp "max time".
//
@@ -368,8 +373,6 @@ namespace mongo {
long long getExpectedLatencyMs() const { return _expectedLatencyMs; }
void setExpectedLatencyMs( long long latency ) { _expectedLatencyMs = latency; }
- void recordGlobalTime(bool isWriteLocked, long long micros) const;
-
/**
* this should be used very sparingly
* generally the Context should set this up
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index a4c52b97cc6..b1a6c0037b2 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
+#include "mongo/db/stats/top.h"
#include "mongo/s/d_state.h"
namespace mongo {
@@ -108,7 +109,13 @@ namespace mongo {
AutoGetCollectionForRead::~AutoGetCollectionForRead() {
// Report time spent in read lock
- CurOp::get(_txn)->recordGlobalTime(false, _timer.micros());
+ auto currentOp = CurOp::get(_txn);
+ Top::get(_txn->getClient()->getServiceContext()).record(
+ currentOp->getNS(),
+ currentOp->getOp(),
+ -1, // "read locked"
+ _timer.micros(),
+ currentOp->isCommand());
}
@@ -178,7 +185,13 @@ namespace mongo {
// Lock must still be held
invariant(_txn->lockState()->isLocked());
- CurOp::get(_txn)->recordGlobalTime(_txn->lockState()->isWriteLocked(), _timer.micros());
+ auto currentOp = CurOp::get(_txn);
+ Top::get(_txn->getClient()->getServiceContext()).record(
+ currentOp->getNS(),
+ currentOp->getOp(),
+ _txn->lockState()->isWriteLocked() ? 1 : -1,
+ _timer.micros(),
+ currentOp->isCommand());
}