summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-03-29 19:35:27 -0400
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-04-20 14:42:08 -0400
commitc09d38c2de92bb0227cc273767ec4a9c22702cc0 (patch)
treec24f7efd2c1a79436275c10a2eb9dfd43017fba3
parentca9aed9d8ed7cba741064304038dc8d10752926f (diff)
downloadmongo-c09d38c2de92bb0227cc273767ec4a9c22702cc0.tar.gz
SERVER-17465 Do not attempt to use tcmalloc customizations with system tcmalloc
(cherry picked from commit 02a9fd0daf29dbd0557d51701444bd95a43868f1)
-rw-r--r--src/mongo/SConscript24
-rw-r--r--src/mongo/db/commands/cpuprofile.cpp2
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp4
-rw-r--r--src/mongo/util/tcmalloc_set_parameter.cpp2
-rw-r--r--src/third_party/SConscript2
5 files changed, 29 insertions, 5 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 31a178eeda6..e0ac7b1c914 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -10,6 +10,7 @@ Import("env")
Import("has_option")
Import("get_option")
Import("usev8")
+Import("use_system_version_of_library")
Import("v8suffix")
Import("darwin windows solaris linux nix")
Import("wiredtiger")
@@ -451,7 +452,20 @@ env.CppUnitTest(
)
if get_option('allocator') == 'tcmalloc':
- env.Library('tcmalloc_set_parameter',
+ tcmspEnv = env.Clone()
+
+ if not use_system_version_of_library('tcmalloc'):
+
+ # Add in the include path for our vendored tcmalloc.
+ tcmspEnv.InjectThirdPartyIncludePaths('gperftools')
+
+ # If our changes to tcmalloc are ever upstreamed, this should become set based on a top
+ # level configure check, though its effects should still be scoped just to these files.
+ tcmspEnv.Append(
+ CPPDEFINES=['MONGO_HAVE_GPERFTOOLS_GET_THREAD_CACHE_SIZE']
+ )
+
+ tcmspEnv.Library('tcmalloc_set_parameter',
[
'util/tcmalloc_server_status_section.cpp',
'util/tcmalloc_set_parameter.cpp',
@@ -874,6 +888,14 @@ env.CppUnitTest("fail_point_test", [ "util/fail_point_test.cpp" ],
if has_option( 'use-cpu-profiler' ):
serverOnlyFiles.append( 'db/commands/cpuprofile.cpp' )
env.Append(LIBS=['unwind'])
+ # If we are building with our internal gperftools, add the necessary include path.
+ #
+ # NOTE: This is pretty bad because it will spam this include path into many files that
+ # don't require it, but because of the way things are currently set up, it is not easy to
+ # scope it more narrowly. Better would be if the commands were a library, and could be
+ # conditionally made to depend on this file, as a library and then we could easily scope
+ # just to this file.
+ env.InjectThirdPartyIncludePaths('tcmalloc')
env.Library("defaultversion", "s/default_version.cpp")
diff --git a/src/mongo/db/commands/cpuprofile.cpp b/src/mongo/db/commands/cpuprofile.cpp
index 44cae32b50c..21198eff28b 100644
--- a/src/mongo/db/commands/cpuprofile.cpp
+++ b/src/mongo/db/commands/cpuprofile.cpp
@@ -47,7 +47,7 @@
* scons --release --use-cpu-profiler
*/
-#include "third_party/gperftools-2.2/src/gperftools/profiler.h"
+#include "gperftools/profiler.h"
#include <string>
#include <vector>
diff --git a/src/mongo/util/tcmalloc_server_status_section.cpp b/src/mongo/util/tcmalloc_server_status_section.cpp
index ab12f6c98b2..2ce4018e6f8 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -29,7 +29,7 @@
#include "mongo/platform/basic.h"
-#include <third_party/gperftools-2.2/src/gperftools/malloc_extension.h>
+#include "gperftools/malloc_extension.h"
#include "mongo/base/init.h"
#include "mongo/db/commands/server_status.h"
@@ -57,6 +57,7 @@ namespace {
return;
}
+#if MONGO_HAVE_GPERFTOOLS_GET_THREAD_CACHE_SIZE
size_t threadCacheSizeBytes = MallocExtension::instance()->GetThreadCacheSize();
static const size_t kMaxThreadCacheSizeBytes = 0x10000;
@@ -69,6 +70,7 @@ namespace {
LOG(1) << "thread over memory limit, cleaning up, current: "
<< (threadCacheSizeBytes/1024) << "k";
+#endif
// We synchronize as the tcmalloc central list uses a spinlock, and we can cause a really
// terrible runaway if we're not careful.
diff --git a/src/mongo/util/tcmalloc_set_parameter.cpp b/src/mongo/util/tcmalloc_set_parameter.cpp
index c0d7a912e04..137b368ca8a 100644
--- a/src/mongo/util/tcmalloc_set_parameter.cpp
+++ b/src/mongo/util/tcmalloc_set_parameter.cpp
@@ -28,7 +28,7 @@
#include "mongo/platform/basic.h"
-#include <third_party/gperftools-2.2/src/gperftools/malloc_extension.h>
+#include "gperftools/malloc_extension.h"
#include "mongo/base/disallow_copying.h"
#include "mongo/base/init.h"
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
index c85530e1b6f..c9087ec4235 100644
--- a/src/third_party/SConscript
+++ b/src/third_party/SConscript
@@ -13,7 +13,7 @@ thirdPartyIncludePathList = [
if not use_system_version_of_library('tcmalloc'):
thirdPartyIncludePathList.append(
- ('gperftools', '#/src/third_party/gperftools-2.2'))
+ ('gperftools', '#/src/third_party/gperftools-2.2/src'))
if not use_system_version_of_library('pcre'):
thirdPartyIncludePathList.append(