summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaley Chen <waleycz@gmail.com>2016-09-13 18:13:34 -0400
committerWaley Chen <waleycz@gmail.com>2016-09-13 18:13:34 -0400
commit6471618952c8727bc5b06039ed2cf861e1a36436 (patch)
treee2b5ab9461919b265a7d929d0e22f457b7409671
parent955cf8c998a60a8c2a2493dd428dd3d763e90259 (diff)
downloadmongo-6471618952c8727bc5b06039ed2cf861e1a36436.tar.gz
Revert "SERVER-22688 Provide a setParameter and shell option to control the js heap limit"
This reverts commit 955cf8c998a60a8c2a2493dd428dd3d763e90259.
-rw-r--r--jstests/core/jsHeapLimit.js22
-rw-r--r--src/mongo/scripting/engine.h3
-rw-r--r--src/mongo/scripting/mozjs/engine.cpp9
-rw-r--r--src/mongo/scripting/mozjs/engine.h3
-rw-r--r--src/mongo/scripting/mozjs/global.cpp8
-rw-r--r--src/mongo/scripting/mozjs/global.h3
-rw-r--r--src/mongo/scripting/mozjs/implscope.cpp19
-rw-r--r--src/mongo/shell/dbshell.cpp1
-rw-r--r--src/mongo/shell/shell_options.cpp13
-rw-r--r--src/mongo/shell/shell_options.h2
10 files changed, 13 insertions, 70 deletions
diff --git a/jstests/core/jsHeapLimit.js b/jstests/core/jsHeapLimit.js
deleted file mode 100644
index abd10376c8a..00000000000
--- a/jstests/core/jsHeapLimit.js
+++ /dev/null
@@ -1,22 +0,0 @@
-(function() {
- "use strict";
-
- const options = {setParameter: "jsHeapMBLimit=1000"};
- const conn = MongoRunner.runMongod(options);
-
- // verify JSHeapMBLimit set from the shell
- var assertLimit = function() {
- assert.eq(999, getJSHeapMBLimit());
- };
- var exitCode = runMongoProgram(
- "mongo", conn.host, "--jsHeapMBLimit", 999, "--eval", "(" + assertLimit.toString() + ")();");
- assert.eq(0, exitCode);
-
- // verify the JSHeapMBLimit set from Mongod
- const db = conn.getDB('test');
- const res = db.adminCommand({getParameter: 1, jsHeapMBLimit: 1});
- assert.commandWorked(res);
- assert.eq(1000, res.jsHeapMBLimit);
-
- MongoRunner.stopMongod(conn);
-})(); \ No newline at end of file
diff --git a/src/mongo/scripting/engine.h b/src/mongo/scripting/engine.h
index 06f4e7d0e6a..df6760f9014 100644
--- a/src/mongo/scripting/engine.h
+++ b/src/mongo/scripting/engine.h
@@ -249,9 +249,6 @@ public:
virtual void enableJavaScriptProtection(bool value) = 0;
virtual bool isJavaScriptProtectionEnabled() const = 0;
- virtual int getJSHeapMBLimit() const = 0;
- virtual void setJSHeapMBLimit(int limit) = 0;
-
static void setup();
static void dropScopeCache();
diff --git a/src/mongo/scripting/mozjs/engine.cpp b/src/mongo/scripting/mozjs/engine.cpp
index d854a098fdc..90038dbea35 100644
--- a/src/mongo/scripting/mozjs/engine.cpp
+++ b/src/mongo/scripting/mozjs/engine.cpp
@@ -50,7 +50,6 @@ namespace {
MONGO_EXPORT_SERVER_PARAMETER(disableJavaScriptJIT, bool, false);
MONGO_EXPORT_SERVER_PARAMETER(javascriptProtection, bool, false);
-MONGO_EXPORT_SERVER_PARAMETER(jsHeapMBLimit, int, 1100);
} // namespace
@@ -138,14 +137,6 @@ bool MozJSScriptEngine::isJavaScriptProtectionEnabled() const {
return javascriptProtection.load();
}
-int MozJSScriptEngine::getJSHeapMBLimit() const {
- return jsHeapMBLimit.load();
-}
-
-void MozJSScriptEngine::setJSHeapMBLimit(int limit) {
- jsHeapMBLimit.store(limit);
-}
-
void MozJSScriptEngine::registerOperation(OperationContext* txn, MozJSImplScope* scope) {
stdx::lock_guard<stdx::mutex> giLock(_globalInterruptLock);
diff --git a/src/mongo/scripting/mozjs/engine.h b/src/mongo/scripting/mozjs/engine.h
index 8cbbc4e3de5..8d6cf201e5f 100644
--- a/src/mongo/scripting/mozjs/engine.h
+++ b/src/mongo/scripting/mozjs/engine.h
@@ -69,9 +69,6 @@ public:
void enableJavaScriptProtection(bool value) override;
bool isJavaScriptProtectionEnabled() const override;
- int getJSHeapMBLimit() const override;
- void setJSHeapMBLimit(int limit) override;
-
void registerOperation(OperationContext* ctx, MozJSImplScope* scope);
void unregisterOperation(unsigned int opId);
diff --git a/src/mongo/scripting/mozjs/global.cpp b/src/mongo/scripting/mozjs/global.cpp
index 9ea7a5c24a9..105d9478dba 100644
--- a/src/mongo/scripting/mozjs/global.cpp
+++ b/src/mongo/scripting/mozjs/global.cpp
@@ -35,7 +35,6 @@
#include "mongo/base/init.h"
#include "mongo/logger/logger.h"
#include "mongo/logger/logstream_builder.h"
-#include "mongo/scripting/engine.h"
#include "mongo/scripting/mozjs/implscope.h"
#include "mongo/scripting/mozjs/jsstringwrapper.h"
#include "mongo/scripting/mozjs/objectwrapper.h"
@@ -45,12 +44,11 @@
namespace mongo {
namespace mozjs {
-const JSFunctionSpec GlobalInfo::freeFunctions[6] = {
+const JSFunctionSpec GlobalInfo::freeFunctions[5] = {
MONGO_ATTACH_JS_FUNCTION(gc),
MONGO_ATTACH_JS_FUNCTION(print),
MONGO_ATTACH_JS_FUNCTION(version),
MONGO_ATTACH_JS_FUNCTION(buildInfo),
- MONGO_ATTACH_JS_FUNCTION(getJSHeapMBLimit),
JS_FS_END,
};
@@ -98,10 +96,6 @@ void GlobalInfo::Functions::buildInfo::call(JSContext* cx, JS::CallArgs args) {
ValueReader(cx, args.rval()).fromBSON(b.obj(), nullptr, false);
}
-void GlobalInfo::Functions::getJSHeapMBLimit::call(JSContext* cx, JS::CallArgs args) {
- ValueReader(cx, args.rval()).fromDouble(mongo::globalScriptEngine->getJSHeapMBLimit());
-}
-
void GlobalInfo::Functions::gc::call(JSContext* cx, JS::CallArgs args) {
auto scope = getScope(cx);
diff --git a/src/mongo/scripting/mozjs/global.h b/src/mongo/scripting/mozjs/global.h
index 342f4347a5b..b90fa3c7682 100644
--- a/src/mongo/scripting/mozjs/global.h
+++ b/src/mongo/scripting/mozjs/global.h
@@ -45,10 +45,9 @@ struct GlobalInfo : public BaseInfo {
MONGO_DECLARE_JS_FUNCTION(print);
MONGO_DECLARE_JS_FUNCTION(version);
MONGO_DECLARE_JS_FUNCTION(buildInfo);
- MONGO_DECLARE_JS_FUNCTION(getJSHeapMBLimit);
};
- static const JSFunctionSpec freeFunctions[6];
+ static const JSFunctionSpec freeFunctions[5];
static const char* const className;
static const unsigned classFlags = JSCLASS_GLOBAL_FLAGS;
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp
index dc50f8cf026..399a1e532f9 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -67,6 +67,13 @@ const char* const MozJSImplScope::kInvokeResult = "__returnValue";
namespace {
/**
+ * The maximum amount of memory to be given out per thread to mozilla. We
+ * manage this by trapping all calls to malloc, free, etc. and keeping track of
+ * counts in some thread locals
+ */
+const size_t kMallocMemoryLimit = 1024ul * 1024 * 1024 * 1.1;
+
+/**
* The threshold (as a fraction of the max) after which garbage collection will be run during
* interrupts.
*/
@@ -244,13 +251,7 @@ void MozJSImplScope::_gcCallback(JSRuntime* rt, JSGCStatus status, void* data) {
}
MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) {
- /**
- * The maximum amount of memory to be given out per thread to mozilla. We
- * manage this by trapping all calls to malloc, free, etc. and keeping track of
- * counts in some thread locals
- */
- size_t mallocMemoryLimit = 1024ul * 1024 * engine->getJSHeapMBLimit();
- mongo::sm::reset(mallocMemoryLimit);
+ mongo::sm::reset(kMallocMemoryLimit);
// If this runtime isn't running on an NSPR thread, then it is
// running on a mongo thread. In that case, we need to insert a
@@ -317,7 +318,7 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) {
}
// The memory limit is in megabytes
- JS_SetGCParametersBasedOnAvailableMemory(_runtime, engine->getJSHeapMBLimit());
+ JS_SetGCParametersBasedOnAvailableMemory(_runtime, kMallocMemoryLimit / (1024 * 1024));
}
_context = JS_NewContext(_runtime, kStackChunkSize);
@@ -779,6 +780,8 @@ void MozJSImplScope::externalSetup() {
if (_connectState == ConnectState::Local)
uasserted(12512, "localConnect already called, can't call externalSetup");
+ mongo::sm::reset(0);
+
// install db access functions in the global object
installDBAccess();
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 768c8558efd..5df9fc23679 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -708,7 +708,6 @@ int _main(int argc, char* argv[], char** envp) {
mongo::ScriptEngine::setConnectCallback(mongo::shell_utils::onConnect);
mongo::ScriptEngine::setup();
- mongo::globalScriptEngine->setJSHeapMBLimit(shellGlobalParams.jsHeapMBLimit);
mongo::globalScriptEngine->setScopeInitCallback(mongo::shell_utils::initScope);
mongo::globalScriptEngine->enableJIT(!shellGlobalParams.nojit);
mongo::globalScriptEngine->enableJavaScriptProtection(shellGlobalParams.javascriptProtection);
diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp
index 324ad87fa3d..1b378836c35 100644
--- a/src/mongo/shell/shell_options.cpp
+++ b/src/mongo/shell/shell_options.cpp
@@ -200,9 +200,6 @@ Status addMongoShellOptions(moe::OptionSection* options) {
if (!ret.isOK())
return ret;
- options->addOptionChaining(
- "jsHeapMBLimit", "jsHeapMBLimit", moe::Int, "set the js scope's heap size limit");
-
return Status::OK();
}
@@ -373,16 +370,6 @@ Status storeMongoShellOptions(const moe::Environment& params,
}
}
- if (params.count("jsHeapMBLimit")) {
- int jsHeapMBLimit = params["jsHeapMBLimit"].as<int>();
- if (jsHeapMBLimit <= 0) {
- StringBuilder sb;
- sb << "ERROR: \"jsHeapMBLimit\" needs to be greater than 0";
- return Status(ErrorCodes::BadValue, sb.str());
- }
- shellGlobalParams.jsHeapMBLimit = jsHeapMBLimit;
- }
-
if (shellGlobalParams.url == "*") {
StringBuilder sb;
sb << "ERROR: "
diff --git a/src/mongo/shell/shell_options.h b/src/mongo/shell/shell_options.h
index 296567025e3..62191bfb0c9 100644
--- a/src/mongo/shell/shell_options.h
+++ b/src/mongo/shell/shell_options.h
@@ -73,8 +73,6 @@ struct ShellGlobalParams {
std::string readMode = "compatibility";
boost::optional<rpc::ProtocolSet> rpcProtocols = boost::none;
-
- int jsHeapMBLimit = 0;
};
extern ShellGlobalParams shellGlobalParams;