rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ding...@apache.org
Subject [rocketmq] branch develop updated: fix /dev/shm not found on some OSs (#1345)
Date Tue, 30 Jul 2019 09:28:29 GMT
This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7ac5ad3  fix /dev/shm not found on some OSs (#1345)
7ac5ad3 is described below

commit 7ac5ad37bb64b0cf99a95342b3f2d2286c25016f
Author: Rui Liu <245422695@qq.com>
AuthorDate: Tue Jul 30 17:28:22 2019 +0800

    fix /dev/shm not found on some OSs (#1345)
---
 distribution/benchmark/runclass.sh | 34 +++++++++++++++++++++++++++++++---
 distribution/bin/runbroker.sh      | 30 +++++++++++++++++++++++++++++-
 distribution/bin/runserver.sh      | 33 +++++++++++++++++++++++++++++++--
 3 files changed, 91 insertions(+), 6 deletions(-)

diff --git a/distribution/benchmark/runclass.sh b/distribution/benchmark/runclass.sh
index 13c58d1..339e11a 100644
--- a/distribution/benchmark/runclass.sh
+++ b/distribution/benchmark/runclass.sh
@@ -24,13 +24,41 @@ fi
 BASE_DIR=$(dirname $0)/..
 CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
 
+# The RAMDisk initializing size in MB on Darwin OS for gc-log
+DIR_SIZE_IN_MB=600
+
+choose_gc_log_directory()
+{
+    case "`uname`" in
+        Darwin)
+            if [ ! -d "/Volumes/RAMDisk" ]; then
+                # create ram disk on Darwin systems as gc-log directory
+                DEV=`hdiutil attach -nomount ram://$((2 * 1024 * DIR_SIZE_IN_MB))` > /dev/null
+                diskutil eraseVolume HFS+ RAMDisk ${DEV} > /dev/null
+                echo "Create RAMDisk /Volumes/RAMDisk for gc logging on Darwin OS."
+            fi
+            GC_LOG_DIR="/Volumes/RAMDisk"
+        ;;
+        *)
+            # check if /dev/shm exists on other systems
+            if [ -d "/dev/shm" ]; then
+                GC_LOG_DIR="/dev/shm"
+            else
+                GC_LOG_DIR=${BASE_DIR}
+            fi
+        ;;
+    esac
+}
+
+choose_gc_log_directory
+
 JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn256m -XX:PermSize=128m -XX:MaxPermSize=320m"
 JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled
-XX:SurvivorRatio=8 -XX:+DisableExplicitGC"
-JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
+JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_run_class_gc_%p_%t.log -XX:+PrintGCDetails"
 JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
 JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${BASE_DIR}/lib"
-JAVA_OPT="${JAVA_OPT}  -XX:-UseLargePages"
-JAVA_OPT="${JAVA_OPT}  -XX:+PerfDisableSharedMem"
+JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
+JAVA_OPT="${JAVA_OPT} -XX:+PerfDisableSharedMem"
 #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
 JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
 
diff --git a/distribution/bin/runbroker.sh b/distribution/bin/runbroker.sh
index df962b4..0ccbf77 100644
--- a/distribution/bin/runbroker.sh
+++ b/distribution/bin/runbroker.sh
@@ -36,9 +36,37 @@ export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
 #===========================================================================================
 # JVM Configuration
 #===========================================================================================
+# The RAMDisk initializing size in MB on Darwin OS for gc-log
+DIR_SIZE_IN_MB=600
+
+choose_gc_log_directory()
+{
+    case "`uname`" in
+        Darwin)
+            if [ ! -d "/Volumes/RAMDisk" ]; then
+                # create ram disk on Darwin systems as gc-log directory
+                DEV=`hdiutil attach -nomount ram://$((2 * 1024 * DIR_SIZE_IN_MB))` > /dev/null
+                diskutil eraseVolume HFS+ RAMDisk ${DEV} > /dev/null
+                echo "Create RAMDisk /Volumes/RAMDisk for gc logging on Darwin OS."
+            fi
+            GC_LOG_DIR="/Volumes/RAMDisk"
+        ;;
+        *)
+            # check if /dev/shm exists on other systems
+            if [ -d "/dev/shm" ]; then
+                GC_LOG_DIR="/dev/shm"
+            else
+                GC_LOG_DIR=${BASE_DIR}
+            fi
+        ;;
+    esac
+}
+
+choose_gc_log_directory
+
 JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
 JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30
-XX:SoftRefLRUPolicyMSPerMB=0"
-JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps
-XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
+JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails
-XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
 JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
 JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
 JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
diff --git a/distribution/bin/runserver.sh b/distribution/bin/runserver.sh
index 908c79d..d2bbded 100644
--- a/distribution/bin/runserver.sh
+++ b/distribution/bin/runserver.sh
@@ -36,11 +36,40 @@ export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
 #===========================================================================================
 # JVM Configuration
 #===========================================================================================
+# The RAMDisk initializing size in MB on Darwin OS for gc-log
+DIR_SIZE_IN_MB=600
+
+choose_gc_log_directory()
+{
+    case "`uname`" in
+        Darwin)
+            if [ ! -d "/Volumes/RAMDisk" ]; then
+                # create ram disk on Darwin systems as gc-log directory
+                DEV=`hdiutil attach -nomount ram://$((2 * 1024 * DIR_SIZE_IN_MB))` > /dev/null
+                diskutil eraseVolume HFS+ RAMDisk ${DEV} > /dev/null
+                echo "Create RAMDisk /Volumes/RAMDisk for gc logging on Darwin OS."
+            fi
+            GC_LOG_DIR="/Volumes/RAMDisk"
+        ;;
+        *)
+            # check if /dev/shm exists on other systems
+            if [ -d "/dev/shm" ]; then
+                GC_LOG_DIR="/dev/shm"
+            else
+                GC_LOG_DIR=${BASE_DIR}
+            fi
+        ;;
+    esac
+}
+
+choose_gc_log_directory
+
 JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
 JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled
-XX:SurvivorRatio=8  -XX:-UseParNewGC"
-JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
+JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log -XX:+PrintGCDetails"
+JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
 JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
-JAVA_OPT="${JAVA_OPT}  -XX:-UseLargePages"
+JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
 JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
 #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
 JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"


Mime
View raw message