Repository: cassandra
Updated Branches:
  refs/heads/trunk 1b876bc60 -> be2cf1afa


get JEMAlloc debug output out of nodetool output

patch by Robert Stupp; reviewed by Ariel Weisberg for CASSANDRA-10628


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0ff13d2a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0ff13d2a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0ff13d2a

Branch: refs/heads/trunk
Commit: 0ff13d2a6847f7ecba1ac9a26b66714d9e58b60d
Parents: a306a1b
Author: Robert Stupp <sn...@snazy.de>
Authored: Wed Nov 4 23:28:57 2015 +0100
Committer: Robert Stupp <sn...@snazy.de>
Committed: Wed Nov 4 23:28:57 2015 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +-
 bin/cassandra                                   | 49 ++++++++++++++++++++
 conf/cassandra-env.sh                           | 49 --------------------
 .../apache/cassandra/service/StartupChecks.java | 19 +++++++-
 4 files changed, 68 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ff13d2a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 60bf565..fedede2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,5 @@
 2.2.4
- * Deprecate memory_allocator in cassandra.yaml (CASSANDRA-10581)
+ * Deprecate memory_allocator in cassandra.yaml (CASSANDRA-10581,10628)
  * Expose phi values from failure detector via JMX and tweak debug
    and trace logging (CASSANDRA-9526)
  * Fix RangeNamesQueryPager (CASSANDRA-10509)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ff13d2a/bin/cassandra
----------------------------------------------------------------------
diff --git a/bin/cassandra b/bin/cassandra
index 8d7b14f..0bbd9fb 100755
--- a/bin/cassandra
+++ b/bin/cassandra
@@ -132,6 +132,55 @@ case "`uname`" in
     ;;
 esac
 
+# Cassandra uses an installed jemalloc via LD_PRELOAD / DYLD_INSERT_LIBRARIES 
by default to improve off-heap
+# memory allocation performance. The following code searches for an installed 
libjemalloc.dylib/.so/.1.so using
+# Linux and OS-X specific approaches.
+# To specify your own libjemalloc in a different path, configure the fully 
qualified path in CASSANDRA_LIBJEMALLOC.
+# To disable jemalloc preload at all, set CASSANDRA_LIBJEMALLOC=-
+#
+#CASSANDRA_LIBJEMALLOC=
+#
+find_library()
+{
+    pattern=$1
+    path=$(echo ${2} | tr ":" " ")
+
+    find $path -regex "$pattern" -print 2>/dev/null | head -n 1
+}
+case "`uname -s`" in
+    Linux)
+        if [ -z $CASSANDRA_LIBJEMALLOC ] ; then
+            which ldconfig > /dev/null 2>&1
+            if [ $? = 0 ] ; then
+                # e.g. for CentOS
+                dirs="/lib64 /lib /usr/lib64 /usr/lib `ldconfig -v 2>/dev/null 
| grep -v ^$'\t' | sed 's/^\([^:]*\):.*$/\1/'`"
+            else
+                # e.g. for Debian, OpenSUSE
+                dirs="/lib64 /lib /usr/lib64 /usr/lib `cat /etc/ld.so.conf 
/etc/ld.so.conf.d/*.conf | grep '^/'`"
+            fi
+            dirs=`echo $dirs | tr " " ":"`
+            CASSANDRA_LIBJEMALLOC=$(find_library '.*/libjemalloc\.so\(\.1\)*' 
$dirs)
+        fi
+        if [ ! -z $CASSANDRA_LIBJEMALLOC ] ; then
+            export JVM_OPTS="$JVM_OPTS 
-Dcassandra.libjemalloc=$CASSANDRA_LIBJEMALLOC"
+            if [ "-" != "$CASSANDRA_LIBJEMALLOC" ] ; then
+                export LD_PRELOAD=$CASSANDRA_LIBJEMALLOC
+            fi
+        fi
+    ;;
+    Darwin)
+        if [ -z $CASSANDRA_LIBJEMALLOC ] ; then
+            CASSANDRA_LIBJEMALLOC=$(find_library '.*/libjemalloc\.dylib' 
$DYLD_LIBRARY_PATH:${DYLD_FALLBACK_LIBRARY_PATH-$HOME/lib:/usr/local/lib:/lib:/usr/lib})
+        fi
+        if [ ! -z $CASSANDRA_LIBJEMALLOC ] ; then
+            export JVM_OPTS="$JVM_OPTS 
-Dcassandra.libjemalloc=$CASSANDRA_LIBJEMALLOC"
+            if [ "-" != "$CASSANDRA_LIBJEMALLOC" ] ; then
+                export DYLD_INSERT_LIBRARIES=$CASSANDRA_LIBJEMALLOC
+            fi
+        fi
+    ;;
+esac
+
 launch_service()
 {
     pidpath="$1"

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ff13d2a/conf/cassandra-env.sh
----------------------------------------------------------------------
diff --git a/conf/cassandra-env.sh b/conf/cassandra-env.sh
index bb20964..e82198b 100644
--- a/conf/cassandra-env.sh
+++ b/conf/cassandra-env.sh
@@ -160,55 +160,6 @@ then
     export MALLOC_ARENA_MAX=4
 fi
 
-# Cassandra uses an installed jemalloc via LD_PRELOAD / DYLD_INSERT_LIBRARIES 
by default to improve off-heap
-# memory allocation performance. The following code searches for an installed 
libjemalloc.dylib/.so/.1.so using
-# Linux and OS-X specific approaches.
-# To specify your own libjemalloc in a different path, configure the fully 
qualified path in CASSANDRA_LIBJEMALLOC.
-# To disable jemalloc at all set CASSANDRA_LIBJEMALLOC=-
-#
-#CASSANDRA_LIBJEMALLOC=
-#
-find_library()
-{
-    pattern=$1
-    path=$(echo ${2} | tr ":" " ")
-
-    find $path -regex "$pattern" -print 2>/dev/null | head -n 1
-}
-case "`uname -s`" in
-    Linux)
-        if [ -z $CASSANDRA_LIBJEMALLOC ] ; then
-            which ldconfig > /dev/null 2>&1
-            if [ $? = 0 ] ; then
-                # e.g. for CentOS
-                dirs="/lib64 /lib /usr/lib64 /usr/lib `ldconfig -v 2>/dev/null 
| grep -v ^$'\t' | sed 's/^\([^:]*\):.*$/\1/'`"
-            else
-                # e.g. for Debian, OpenSUSE
-                dirs="/lib64 /lib /usr/lib64 /usr/lib `cat /etc/ld.so.conf 
/etc/ld.so.conf.d/*.conf | grep '^/'`"
-            fi
-            dirs=`echo $dirs | tr " " ":"`
-            CASSANDRA_LIBJEMALLOC=$(find_library '.*/libjemalloc\.so\(\.1\)*' 
$dirs)
-        fi
-        if [ ! -z $CASSANDRA_LIBJEMALLOC ] && [ "-" != 
"$CASSANDRA_LIBJEMALLOC" ] ; then
-            echo "INFO preloading $CASSANDRA_LIBJEMALLOC"
-            export LD_PRELOAD=$CASSANDRA_LIBJEMALLOC
-        else
-            echo "WARNING could not find libjemalloc.dylib, please install for 
better performance - search path: $dirs"
-        fi
-    ;;
-    Darwin)
-        if [ -z $CASSANDRA_LIBJEMALLOC ] ; then
-            CASSANDRA_LIBJEMALLOC=$(find_library '.*/libjemalloc\.dylib' 
$DYLD_LIBRARY_PATH:${DYLD_FALLBACK_LIBRARY_PATH-$HOME/lib:/usr/local/lib:/lib:/usr/lib})
-        fi
-        if [ ! -z $CASSANDRA_LIBJEMALLOC ] && [ "-" != 
"$CASSANDRA_LIBJEMALLOC" ] ; then
-            echo "INFO preloading $CASSANDRA_LIBJEMALLOC"
-            export DYLD_INSERT_LIBRARIES=$CASSANDRA_LIBJEMALLOC
-        else
-            echo "WARNING could not find libjemalloc.dylib, please install for 
better performance - search path: 
$DYLD_LIBRARY_PATH:${DYLD_FALLBACK_LIBRARY_PATH-$HOME/lib:/usr/local/lib:/lib:/usr/lib}"
-        fi
-    ;;
-esac
-
 
 # Specifies the default port over which Cassandra will be available for
 # JMX connections.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ff13d2a/src/java/org/apache/cassandra/service/StartupChecks.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StartupChecks.java 
b/src/java/org/apache/cassandra/service/StartupChecks.java
index 4934dea..8b8810c 100644
--- a/src/java/org/apache/cassandra/service/StartupChecks.java
+++ b/src/java/org/apache/cassandra/service/StartupChecks.java
@@ -67,7 +67,8 @@ public class StartupChecks
     // The default set of pre-flight checks to run. Order is somewhat 
significant in that we probably
     // always want the system keyspace check run last, as this actually loads 
the schema for that
     // keyspace. All other checks should not require any schema initialization.
-    private final List<StartupCheck> DEFAULT_TESTS = 
ImmutableList.of(checkValidLaunchDate,
+    private final List<StartupCheck> DEFAULT_TESTS = 
ImmutableList.of(checkJemalloc,
+                                                                      
checkValidLaunchDate,
                                                                       
checkJMXPorts,
                                                                       
inspectJvmOptions,
                                                                       
checkJnaInitialization,
@@ -103,6 +104,22 @@ public class StartupChecks
             test.execute();
     }
 
+    public static final StartupCheck checkJemalloc = new StartupCheck()
+    {
+        public void execute() throws StartupException
+        {
+            if (FBUtilities.isWindows())
+                return;
+            String jemalloc = System.getProperty("cassandra.libjemalloc");
+            if (jemalloc == null)
+                logger.warn("jemalloc shared library could not be preloaded to 
speed up memory allocations");
+            else if ("-".equals(jemalloc))
+                logger.info("jemalloc preload explicitly disabled");
+            else
+                logger.info("jemalloc seems to be preloaded from {}", 
jemalloc);
+        }
+    };
+
     public static final StartupCheck checkValidLaunchDate = new StartupCheck()
     {
         /**

Reply via email to