summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2020-05-17 16:41:54 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-27 16:10:48 +0000
commit17d9094752fec7dd29c9eedac9bd7cccb8cf8f6e (patch)
treee0e00f22fde4e42b99c92db6353e9fcde91b46f6 /src/mongo/db
parent2de03a25a0a3dc8f7e675c33ff9e1b1370532d41 (diff)
downloadmongo-17d9094752fec7dd29c9eedac9bd7cccb8cf8f6e.tar.gz
SERVER-48272 Reduce startup time for dynamically linked binaries
Minimizing the list of NEEDED entries directly attached to the core programs reduces startup time for dynamically linked binaries by approximately 40 percent.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/fts/unicode/SConscript2
-rw-r--r--src/mongo/db/mongod.cpp52
-rw-r--r--src/mongo/db/mongod.manifest.in (renamed from src/mongo/db/db.manifest.in)0
-rw-r--r--src/mongo/db/mongod.rc (renamed from src/mongo/db/db.rc)2
-rw-r--r--src/mongo/db/mongod_initializers.cpp31
-rw-r--r--src/mongo/db/mongod_main.cpp (renamed from src/mongo/db/db.cpp)25
-rw-r--r--src/mongo/db/mongod_main.h34
-rw-r--r--src/mongo/db/storage/SConscript10
-rw-r--r--src/mongo/db/storage/wiredtiger/SConscript7
9 files changed, 133 insertions, 30 deletions
diff --git a/src/mongo/db/fts/unicode/SConscript b/src/mongo/db/fts/unicode/SConscript
index 85f71077606..2b783364d64 100644
--- a/src/mongo/db/fts/unicode/SConscript
+++ b/src/mongo/db/fts/unicode/SConscript
@@ -48,7 +48,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/linenoise_utf8',
+ '$BUILD_DIR/mongo/shell/linenoise_utf8',
]
)
diff --git a/src/mongo/db/mongod.cpp b/src/mongo/db/mongod.cpp
new file mode 100644
index 00000000000..3fd8f53c106
--- /dev/null
+++ b/src/mongo/db/mongod.cpp
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/mongod_main.h"
+#include "mongo/util/quick_exit.h"
+#include "mongo/util/text.h"
+
+#if defined(_WIN32)
+// In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
+// as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters. The
+// WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
+// and makes them available through the argv() and envp() members. This enables mongoDbMain()
+// to process UTF-8 encoded arguments and environment variables without regard to platform.
+int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
+ mongo::WindowsCommandLine wcl(argc, argvW, envpW);
+ int exitCode = mongo::mongod_main(argc, wcl.argv(), wcl.envp());
+ mongo::quickExit(exitCode);
+}
+#else
+int main(int argc, char* argv[], char** envp) {
+ int exitCode = mongo::mongod_main(argc, argv, envp);
+ mongo::quickExit(exitCode);
+}
+#endif
diff --git a/src/mongo/db/db.manifest.in b/src/mongo/db/mongod.manifest.in
index ea9d02d9a83..ea9d02d9a83 100644
--- a/src/mongo/db/db.manifest.in
+++ b/src/mongo/db/mongod.manifest.in
diff --git a/src/mongo/db/db.rc b/src/mongo/db/mongod.rc
index 343ea2d7642..c2fbc5c9751 100644
--- a/src/mongo/db/db.rc
+++ b/src/mongo/db/mongod.rc
@@ -53,4 +53,4 @@ BEGIN
END
END
-CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "mongo/db/db.manifest"
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "mongo/db/mongod.manifest"
diff --git a/src/mongo/db/mongod_initializers.cpp b/src/mongo/db/mongod_initializers.cpp
new file mode 100644
index 00000000000..854bf218172
--- /dev/null
+++ b/src/mongo/db/mongod_initializers.cpp
@@ -0,0 +1,31 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+// This file intentionally blank. mongod_initializers.cpp exists only to provide
+// a compilable source file for systems which cannot produce a library with no sources.
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/mongod_main.cpp
index bc4554893f6..759df7503c3 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/mongod_main.cpp
@@ -31,6 +31,8 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/mongod_main.h"
+
#include <boost/filesystem/operations.hpp>
#include <boost/optional.hpp>
#include <fstream>
@@ -1262,7 +1264,9 @@ void shutdownTask(const ShutdownTaskArgs& shutdownArgs) {
#endif
}
-int mongoDbMain(int argc, char* argv[], char** envp) {
+} // namespace
+
+int mongod_main(int argc, char* argv[], char** envp) {
ThreadSafetyContext::getThreadSafetyContext()->forbidMultiThreading();
registerShutdownTask(shutdownTask);
@@ -1339,23 +1343,4 @@ int mongoDbMain(int argc, char* argv[], char** envp) {
return 0;
}
-} // namespace
} // namespace mongo
-
-#if defined(_WIN32)
-// In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
-// as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters. The
-// WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
-// and makes them available through the argv() and envp() members. This enables mongoDbMain()
-// to process UTF-8 encoded arguments and environment variables without regard to platform.
-int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
- mongo::WindowsCommandLine wcl(argc, argvW, envpW);
- int exitCode = mongo::mongoDbMain(argc, wcl.argv(), wcl.envp());
- mongo::quickExit(exitCode);
-}
-#else
-int main(int argc, char* argv[], char** envp) {
- int exitCode = mongo::mongoDbMain(argc, argv, envp);
- mongo::quickExit(exitCode);
-}
-#endif
diff --git a/src/mongo/db/mongod_main.h b/src/mongo/db/mongod_main.h
new file mode 100644
index 00000000000..0e5a8e06383
--- /dev/null
+++ b/src/mongo/db/mongod_main.h
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+namespace mongo {
+
+int mongod_main(int argc, char* argv[], char** envp);
+
+} // namespace mongo
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index e32b8ba329a..4d5f1ef273b 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -186,9 +186,9 @@ env.Library(
],
LIBDEPS= ['$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/service_context'],
- PROGDEPS_DEPENDENTS=[
- '$BUILD_DIR/mongo/mongod',
- '$BUILD_DIR/mongo/mongos',
+ LIBDEPS_DEPENDENTS=[
+ '$BUILD_DIR/mongo/mongod_initializers',
+ '$BUILD_DIR/mongo/mongos_initializers',
],
)
@@ -201,8 +201,8 @@ env.Library(
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/service_context',
],
- PROGDEPS_DEPENDENTS=[
- '$BUILD_DIR/mongo/mongod',
+ LIBDEPS_DEPENDENTS=[
+ '$BUILD_DIR/mongo/mongod_initializers',
],
)
diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript
index 79bc99ec83a..d679a2ed6b9 100644
--- a/src/mongo/db/storage/wiredtiger/SConscript
+++ b/src/mongo/db/storage/wiredtiger/SConscript
@@ -18,10 +18,11 @@ env.Library(
],
LIBDEPS= ['$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/service_context'],
- PROGDEPS_DEPENDENTS=[
- '$BUILD_DIR/mongo/mongod',
- '$BUILD_DIR/mongo/mongos',
+ LIBDEPS_DEPENDENTS=[
+ '$BUILD_DIR/mongo/mongod_initializers',
+ '$BUILD_DIR/mongo/mongos_initializers',
],
+
)
if wiredtiger: