]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Conditional-compile against minimal tcmalloc. 4008/head
authorThorsten Behrens <tbehrens@suse.com>
Sun, 15 Mar 2015 23:13:38 +0000 (00:13 +0100)
committerThorsten Behrens <tbehrens@suse.com>
Mon, 30 Mar 2015 01:23:45 +0000 (03:23 +0200)
Certain older systems (SLE11 in this case) do not provide the full
tcmalloc functionality, due to e.g. incomplete libunwind
pieces. Use --with-tcmalloc-minimal to enable the cut-down
version.

Here's how the various mem allocator switches interact now:

--with-jemalloc: overrides --with-tcmalloc & --with-tcmalloc-minimal
--with-tcmalloc-minimal: overrides --with-tcmalloc
--with-tcmalloc: the default. use --without-tcmalloc to disable

Signed-off-by: Thorsten Behrens <tbehrens@suse.com>
configure.ac
src/Makefile-env.am
src/perfglue/Makefile.am
src/perfglue/heap_profiler.cc

index 05f0cf9cd91c4f5b9a2f9acca56eb7a9348888ab..5f945c4b173af7d35bea54818ca4d2b66963990f 100644 (file)
@@ -406,6 +406,26 @@ AS_IF([test "x$with_jemalloc" = xyes],
                  [no jemalloc found (do not use --with-jemalloc)])])])
 AM_CONDITIONAL(WITH_JEMALLOC, [test "$HAVE_LIBJEMALLOC" = "1"])
 
+# tcmalloc-minimal?
+AC_ARG_WITH([tcmalloc-minimal],
+           [AS_HELP_STRING([--with-tcmalloc-minimal], [enable minimal tcmalloc support for memory allocations])],
+           [],
+           [with_tcmalloc_minimal=no])
+
+AS_IF([test "x$with_jemalloc" = "xyes"],[with_tcmalloc_minimal=no],[])
+
+TCMALLOC_MINIMAL=
+AS_IF([test "x$with_tcmalloc_minimal" != xno],
+        [AC_CHECK_LIB([tcmalloc_minimal], [malloc],
+         [AC_SUBST([LIBTCMALLOC], ["-ltcmalloc_minimal"])
+              AC_DEFINE([HAVE_LIBTCMALLOC_MINIMAL], [1],
+                        [Define if you have tcmalloc])
+              HAVE_LIBTCMALLOC_MINIMAL=1
+            ],
+           [AC_MSG_FAILURE(
+                 [no tcmalloc found (do not use --with-tcmalloc-minimal)])])])
+AM_CONDITIONAL(WITH_TCMALLOC_MINIMAL, [test "$HAVE_LIBTCMALLOC_MINIMAL" = "1"])
+
 # tcmalloc?
 AC_ARG_WITH([tcmalloc],
            [AS_HELP_STRING([--without-tcmalloc], [disable tcmalloc for memory allocations])],
@@ -413,6 +433,7 @@ AC_ARG_WITH([tcmalloc],
            [with_tcmalloc=yes])
 
 AS_IF([test "x$with_jemalloc" = "xyes"],[with_tcmalloc=no],[])
+AS_IF([test "x$with_tcmalloc_minimal" = "xyes"],[with_tcmalloc=no],[])
 
 TCMALLOC=
 AS_IF([test "x$with_tcmalloc" != xno],
index 8716f15a7845a2dbc240e5a0615d06c6f127947e..4c1e3c73c5ef8efb365e9a0f8943ad844f5d56bf 100644 (file)
@@ -175,6 +175,10 @@ if WITH_LIBROCKSDB
 LIBOS += libos_rocksdb.la
 endif # WITH_LIBROCKSDB
 
+if WITH_TCMALLOC_MINIMAL
+LIBPERFGLUE += -ltcmalloc_minimal
+endif # WITH_TCMALLOC_MINIMAL
+
 if WITH_TCMALLOC
 LIBPERFGLUE += -ltcmalloc
 endif # WITH_TCMALLOC
index f2b8d5030e641ae2faeecd2f9147ecb310c7a001..c4514a03c28cf327a5cc565bb7fa69712dad6783 100644 (file)
@@ -6,7 +6,14 @@ libperfglue_la_LIBADD = -ltcmalloc
 AM_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
 AM_CXXFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
 else
+if WITH_TCMALLOC_MINIMAL
+libperfglue_la_SOURCES += perfglue/heap_profiler.cc
+libperfglue_la_LIBADD = -ltcmalloc_minimal
+AM_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+AM_CXXFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+else
 libperfglue_la_SOURCES += perfglue/disabled_heap_profiler.cc
+endif # WITH_TCMALLOC_MINIMAL
 endif # WITH_TCMALLOC
 
 if WITH_PROFILER
index 0fe1f9a43db7d22f1d9b1046068c18080a61d9b3..a0307ca204d95bf8becb2052373f2a07ed5f322d 100644 (file)
@@ -61,7 +61,11 @@ void ceph_heap_release_free_memory()
 
 bool ceph_heap_profiler_running()
 {
+#ifdef HAVE_LIBTCMALLOC
   return IsHeapProfilerRunning();
+#else
+  return false;
+#endif
 }
 
 static void get_profile_name(char *profile_name, int profile_name_len)
@@ -83,21 +87,27 @@ static void get_profile_name(char *profile_name, int profile_name_len)
 
 void ceph_heap_profiler_start()
 {
+#ifdef HAVE_LIBTCMALLOC
   char profile_name[PATH_MAX];
   get_profile_name(profile_name, sizeof(profile_name)); 
   generic_dout(0) << "turning on heap profiler with prefix "
                  << profile_name << dendl;
   HeapProfilerStart(profile_name);
+#endif
 }
 
 void ceph_heap_profiler_stop()
 {
+#ifdef HAVE_LIBTCMALLOC
   HeapProfilerStop();
+#endif
 }
 
 void ceph_heap_profiler_dump(const char *reason)
 {
+#ifdef HAVE_LIBTCMALLOC
   HeapProfilerDump(reason);
+#endif
 }
 
 #define HEAP_PROFILER_STATS_SIZE 2048
@@ -105,6 +115,7 @@ void ceph_heap_profiler_dump(const char *reason)
 void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
                                        ostream& out)
 {
+#ifdef HAVE_LIBTCMALLOC
   if (cmd.size() == 1 && cmd[0] == "dump") {
     if (!ceph_heap_profiler_running()) {
       out << "heap profiler not running; can't dump";
@@ -124,7 +135,9 @@ void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
   } else if (cmd.size() == 1 && cmd[0] == "release") {
     ceph_heap_release_free_memory();
     out << g_conf->name << " releasing free RAM back to system.";
-  } else if (cmd.size() == 1 && cmd[0] == "stats") {
+  } else
+#endif
+  if (cmd.size() == 1 && cmd[0] == "stats") {
     char heap_stats[HEAP_PROFILER_STATS_SIZE];
     ceph_heap_profiler_stats(heap_stats, sizeof(heap_stats));
     out << g_conf->name << " tcmalloc heap stats:"