diff options
-rw-r--r-- | db/cmdline.h | 5 | ||||
-rw-r--r-- | db/db.cpp | 1 | ||||
-rw-r--r-- | db/dbcommands.cpp | 9 | ||||
-rw-r--r-- | db/dbeval.cpp | 2 | ||||
-rw-r--r-- | db/instance.cpp | 4 | ||||
-rw-r--r-- | shell/db.js | 15 |
6 files changed, 21 insertions, 15 deletions
diff --git a/db/cmdline.h b/db/cmdline.h index 6daf1e175c7..b07125953e1 100644 --- a/db/cmdline.h +++ b/db/cmdline.h @@ -38,7 +38,8 @@ namespace mongo { long long oplogSize; // --oplogSize int defaultProfile; // --profile - + int slowMS; // --time in ms that is "slow" + enum { DefaultDBPort = 27017, ConfigServerPort = 27019, @@ -47,7 +48,7 @@ namespace mongo { CmdLine() : port(DefaultDBPort), quiet(false), notablescan(false), prealloc(true), smallfiles(false), - quota(false), quotaFiles(8), cpu(false), oplogSize(0), defaultProfile(0) + quota(false), quotaFiles(8), cpu(false), oplogSize(0), defaultProfile(0), slowMS(100) { } }; diff --git a/db/db.cpp b/db/db.cpp index 245a66b298c..db198cec3ff 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -592,6 +592,7 @@ int main(int argc, char* argv[], char *envp[] ) ("notablescan", "do not allow table scans") ("syncdelay",po::value<double>(&dataFileSync._sleepsecs)->default_value(60), "seconds between disk syncs (0 for never)") ("profile",po::value<int>(), "0=off 1=slow, 2=all") + ("slowms",po::value<int>(&cmdLine.slowMS)->default_value(100), "value of slow for profile and console log" ) ("maxConns",po::value<int>(), "max number of simultaneous connections") #if defined(_WIN32) ("install", "install mongodb service") diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index c9601a16735..35eef287596 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -298,6 +298,11 @@ namespace mongo { else if ( p >= 0 && p <= 2 ) { ok = cc().database()->setProfilingLevel( p , errmsg ); } + + BSONElement slow = cmdObj["slowms"]; + if ( slow.isNumber() ) + cmdLine.slowMS = slow.numberInt(); + return ok; } } cmdProfile; @@ -857,7 +862,7 @@ namespace mongo { BtreeCursor c( d, idxNo, *id, min, max, false, 1 ); for( ; num; c.advance(), --num ); int ms = t.millis(); - if ( ms > 100 ) { + if ( ms > cmdLine.slowMS ) { out() << "Finding median for index: " << keyPattern << " between " << min << " and " << max << " took " << ms << "ms." << endl; } @@ -912,7 +917,7 @@ namespace mongo { numObjects++; } int ms = t.millis(); - if ( ms > 100 ) { + if ( ms > cmdLine.slowMS ) { if ( min.isEmpty() ) { out() << "Finding size for ns: " << ns << " took " << ms << "ms." << endl; } else { diff --git a/db/dbeval.cpp b/db/dbeval.cpp index 7f5b74ff80e..e72913595ed 100644 --- a/db/dbeval.cpp +++ b/db/dbeval.cpp @@ -88,7 +88,7 @@ namespace mongo { Timer t; res = s->invoke(f,args, cmdLine.quota ? 10 * 60 * 1000 : 0 ); int m = t.millis(); - if ( m > 100 ) { + if ( m > cmdLine.slowMS ) { out() << "dbeval slow, time: " << dec << m << "ms " << ns << endl; if ( m >= 1000 ) log() << code << endl; else OCCASIONALLY log() << code << endl; diff --git a/db/instance.cpp b/db/instance.cpp index fb2acc07585..13973011484 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -263,7 +263,7 @@ namespace mongo { currentOp.reset( client); currentOp.setOp(op); - int logThreshold = 100; + int logThreshold = cmdLine.slowMS; bool log = logLevel >= 1; Timer t( currentOp.startTime() ); @@ -387,7 +387,7 @@ namespace mongo { } Database *database = cc().database(); if ( database && database->profile >= 1 ) { - if ( database->profile >= 2 || ms >= 100 ) { + if ( database->profile >= 2 || ms >= cmdLine.slowMS ) { // performance profiling is on if ( dbMutex.getState() > 1 || dbMutex.getState() < -1 ){ out() << "warning: not profiling because recursive lock" << endl; diff --git a/shell/db.js b/shell/db.js index 118c3e44ac5..ab79e22a1bd 100644 --- a/shell/db.js +++ b/shell/db.js @@ -268,7 +268,7 @@ DB.prototype.help = function() { print("\tdb.repairDatabase()"); print("\tdb.resetError()"); print("\tdb.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into { cmdObj : 1 }"); - print("\tdb.setProfilingLevel(level) 0=off 1=slow 2=all"); + print("\tdb.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all"); print("\tdb.shutdownServer()"); print("\tdb.version() current version of the server" ); } @@ -298,17 +298,16 @@ DB.prototype.printCollectionStats = function(){ * @param {String} level Desired level of profiling * @return SOMETHING_FIXME or null on error */ -DB.prototype.setProfilingLevel = function(level) { +DB.prototype.setProfilingLevel = function(level,slowms) { if (level < 0 || level > 2) { throw { dbSetProfilingException : "input level " + level + " is out of range [0..2]" }; } - - if (level) { - // if already exists does nothing - this.createCollection("system.profile", { capped: true, size: 128 * 1024 } ); - } - return this._dbCommand( { profile: level } ); + + var cmd = { profile: level }; + if ( slowms ) + cmd["slowms"] = slowms; + return this._dbCommand( cmd ); } |