This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 1242e37  Provide memory & gc options in bookkeeper script
1242e37 is described below

commit 1242e3757c3dffd3c846787756c49779aee31d13
Author: Sijie Guo <si...@apache.org>
AuthorDate: Mon Apr 16 23:56:29 2018 -0700

    Provide memory & gc options in bookkeeper script
    
    Descriptions of the changes in this PR:
    
    It is convenient to provide `MEM_OPTS` and `GC_OPTS` in bookkeeper script 
and bkenv.sh to allow overriding jvm settings through.
    
    Author: Sijie Guo <si...@apache.org>
    
    Reviewers: Enrico Olivelli <eolive...@gmail.com>
    
    This closes #1342 from sijie/gc_settings
---
 .gitignore     |  3 +++
 bin/bookkeeper | 42 +++++++++++++++++++++++++++++++++++++++---
 conf/bkenv.sh  | 27 +++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 15ad27f..6a111c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,6 @@ lib/
 log/
 target/
 dependency-reduced-pom.xml
+
+# Logs
+logs/
diff --git a/bin/bookkeeper b/bin/bookkeeper
index 3ceefe5..e2bd30e 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -207,20 +207,56 @@ if [ -z "$BOOKIE_LOG_CONF" ]; then
   BOOKIE_LOG_CONF=$DEFAULT_LOG_CONF
 fi
 
+BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"}
+if [ ! -d ${BOOKIE_LOG_DIR} ]; then
+    mkdir ${BOOKIE_LOG_DIR}
+fi
+
+# Configure JVM settings
+DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
+    -XX:MaxGCPauseMillis=10 \
+    -XX:+ParallelRefProcEnabled \
+    -XX:+UnlockExperimentalVMOptions \
+    -XX:+AggressiveOpts \
+    -XX:+DoEscapeAnalysis \
+    -XX:ParallelGCThreads=32 \
+    -XX:ConcGCThreads=32 \
+    -XX:G1NewSizePercent=50 \
+    -XX:+DisableExplicitGC \
+    -XX:-ResizePLAB"
+DEFAULT_BOOKIE_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
+    -XX:+PrintGCApplicationStoppedTime  \
+    -XX:+UseGCLogFileRotation \
+    -XX:NumberOfGCLogFiles=5 \
+    -XX:GCLogFileSize=64m \
+    -Xloggc:${BOOKIE_LOG_DIR}/gc_%p.log"
+BOOKIE_MAX_HEAP_MEMORY=${BOOKIE_MAX_HEAP_MEMORY:-"1g"}
+BOOKIE_MIN_HEAP_MEMORY=${BOOKIE_MIN_HEAP_MEMORY:-"1g"}
+BOOKIE_MAX_DIRECT_MEMORY=${BOOKIE_MAX_DIRECT_MEMORY:-"2g"}
+BOOKIE_MEM_OPTS=${BOOKIE_MEM_OPTS:-"-Xms${BOOKIE_MAX_HEAP_MEMORY} 
-Xmx${BOOKIE_MIN_HEAP_MEMORY} 
-XX:MaxDirectMemorySize=${BOOKIE_MAX_DIRECT_MEMORY}"}
+BOOKIE_GC_OPTS=${BOOKIE_GC_OPTS:-"${DEFAULT_BOOKIE_GC_OPTS}"}
+BOOKIE_GC_LOGGING_OPTS=${BOOKIE_GC_LOGGING_OPTS:-"${DEFAULT_BOOKIE_GC_LOGGING_OPTS}"}
+
 BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH"
 BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH"
 OPTS="$OPTS -Dlog4j.configuration=`basename $BOOKIE_LOG_CONF`"
 
 OPTS="-cp $BOOKIE_CLASSPATH $OPTS"
 
-OPTS="$OPTS $BOOKIE_EXTRA_OPTS"
-
 # Disable ipv6 as it can cause issues
 OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
+# Disable netty leak detection
+NETTY_LEAK_DETECTION_LEVEL=${NETTY_LEAK_DETECTION_LEVEL:-"disabled"}
+OPTS="$OPTS -Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}"
+NETTY_RECYCLER_MAXCAPACITY=${NETTY_RECYCLER_MAXCAPACITY:-"1000"}
+OPTS="$OPTS 
-Dio.netty.recycler.maxCapacity.default=${NETTY_RECYCLER_MAXCAPACITY}"
+NETTY_RECYCLER_LINKCAPACITY=${NETTY_RECYCLER_LINKCAPACITY:-"1024"}
+OPTS="$OPTS -Dio.netty.recycler.linkCapacity=${NETTY_RECYCLER_LINKCAPACITY}"
+
+OPTS="$OPTS $BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS 
$BOOKIE_PERF_OPTS $BOOKIE_EXTRA_OPTS"
 
 # log directory & file
 BOOKIE_ROOT_LOGGER=${BOOKIE_ROOT_LOGGER:-"INFO,CONSOLE"}
-BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"}
 BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"}
 
 #Configure log configuration system properties
diff --git a/conf/bkenv.sh b/conf/bkenv.sh
index 8900b3d..0cb39ec 100644
--- a/conf/bkenv.sh
+++ b/conf/bkenv.sh
@@ -32,6 +32,33 @@
 # Logs location
 # BOOKIE_LOG_DIR=
 
+# JVM memory options
+
+# BOOKIE_MAX_HEAP_MEMORY=1g
+# BOOKIE_MIN_HEAP_MEMORY=1g
+# BOOKIE_MAX_DIRECT_MEMORY=2g
+# BOOKIE_MEM_OPTS=
+
+# JVM GC options
+# BOOKIE_GC_OPTS=
+
+# JVM GC logging options
+# BOOKIE_GC_LOGGING_OPTS=
+
+# JVM performance options
+# BOOKIE_PERF_OPTS="-XX:+PerfDisableSharedMem -XX:+AlwaysPreTouch 
-XX:-UseBiasedLocking"
+
+# Netty options
+
+# netty buffer leak detection level - {@link 
http://netty.io/wiki/reference-counted-objects.html#wiki-h3-11}
+# NETTY_LEAK_DETECTION_LEVEL=
+
+# netty recycler max capacity
+# NETTY_RECYCLER_MAXCAPACITY=
+
+# netty recycler link capacity
+# NETTY_RECYCLER_LINKCAPACITY=
+
 # Extra options to be passed to the jvm
 # BOOKIE_EXTRA_OPTS=
 

-- 
To stop receiving notification emails like this one, please contact
si...@apache.org.

Reply via email to