From ce0265c7e795b222a0013f6ddc9abf04f9f01a1e Mon Sep 17 00:00:00 2001 From: Andreas Mager Date: Fri, 14 Apr 2017 15:21:56 +0200 Subject: [PATCH] distri/moquette.sh: gc1 parameters added distri/moquette.sh: line delimeter changed to unix style --- distribution/src/main/scripts/moquette.bat | 132 ++++++++++++++------- distribution/src/main/scripts/moquette.sh | 47 +++++++- 2 files changed, 130 insertions(+), 49 deletions(-) diff --git a/distribution/src/main/scripts/moquette.bat b/distribution/src/main/scripts/moquette.bat index 5502de87..fc2335ed 100644 --- a/distribution/src/main/scripts/moquette.bat +++ b/distribution/src/main/scripts/moquette.bat @@ -1,45 +1,87 @@ -@ECHO OFF -rem # -rem # Copyright (c) 2012-2015 Andrea Selva -rem # - -echo " " -echo " ___ ___ _ _ ___ ________ _____ _____ " -echo " | \/ | | | | | | \/ | _ |_ _|_ _| " -echo " | . . | ___ __ _ _ _ ___| |_| |_ ___ | . . | | | | | | | | " -echo " | |\/| |/ _ \ / _\ | | | |/ _ \ __| __/ _ \ | |\/| | | | | | | | | " -echo " | | | | (_) | (_| | |_| | __/ |_| || __/ | | | \ \/' / | | | | " -echo " \_| |_/\___/ \__, |\__,_|\___|\__|\__\___| \_| |_/\_/\_\ \_/ \_/ " -echo " | | " -echo " |_| " -echo " " - -set "CURRENT_DIR=%cd%" -if not "%MOQUETTE_HOME%" == "" goto gotHome -set "MOQUETTE_HOME=%CURRENT_DIR%" -if exist "%MOQUETTE_HOME%\bin\moquette.bat" goto okHome -cd .. -set "MOQUETTE_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%MOQUETTE_HOME%\bin\moquette.bat" goto okHome - echo The MOQUETTE_HOME environment variable is not defined correctly - echo This environment variable is needed to run this program -goto end -:okHome - -rem Set JavaHome if it exists -if exist { "%JAVA_HOME%\bin\java" } ( - set "JAVA="%JAVA_HOME%\bin\java"" -) - -echo Using JAVA_HOME: "%JAVA_HOME%" -echo Using MOQUETTE_HOME: "%MOQUETTE_HOME%" - -rem set LOG_CONSOLE_LEVEL=info -rem set LOG_FILE_LEVEL=fine -set JAVA_OPTS= -set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true -set MOQUETTE_PATH=%MOQUETTE_HOME% -set LOG_FILE=%MOQUETTE_HOME%\config\moquette-log.properties -%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dmoquette.path=%MOQUETTE_PATH% -cp %MOQUETTE_HOME%\lib\* io.moquette.server.Server +@ECHO OFF +rem # +rem # Copyright (c) 2012-2015 Andrea Selva +rem # + +echo " " +echo " ___ ___ _ _ ___ ________ _____ _____ " +echo " | \/ | | | | | | \/ | _ |_ _|_ _| " +echo " | . . | ___ __ _ _ _ ___| |_| |_ ___ | . . | | | | | | | | " +echo " | |\/| |/ _ \ / _\ | | | |/ _ \ __| __/ _ \ | |\/| | | | | | | | | " +echo " | | | | (_) | (_| | |_| | __/ |_| || __/ | | | \ \/' / | | | | " +echo " \_| |_/\___/ \__, |\__,_|\___|\__|\__\___| \_| |_/\_/\_\ \_/ \_/ " +echo " | | " +echo " |_| " +echo " " + +set "CURRENT_DIR=%cd%" +if not "%MOQUETTE_HOME%" == "" goto gotHome +set "MOQUETTE_HOME=%CURRENT_DIR%" +if exist "%MOQUETTE_HOME%\bin\moquette.bat" goto okHome +cd .. +set "MOQUETTE_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%MOQUETTE_HOME%\bin\moquette.bat" goto okHome + echo The MOQUETTE_HOME environment variable is not defined correctly + echo This environment variable is needed to run this program +goto end +:okHome + +rem Set JavaHome if it exists +if exist { "%JAVA_HOME%\bin\java" } ( + set "JAVA="%JAVA_HOME%\bin\java"" +) + +echo Using JAVA_HOME: "%JAVA_HOME%" +echo Using MOQUETTE_HOME: "%MOQUETTE_HOME%" + +rem set LOG_CONSOLE_LEVEL=info +rem set LOG_FILE_LEVEL=fine +set JAVA_OPTS= +set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true +set MOQUETTE_PATH=%MOQUETTE_HOME% +set LOG_FILE=%MOQUETTE_HOME%\config\moquette-log.properties + +## Use the Hotspot garbage-first collector. +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseG1GC + +## Have the JVM do less remembered set work during STW, instead +## preferring concurrent GC. Reduces p99.9 latency. +set JAVA_OPTS=%JAVA_OPTS% -XX:G1RSetUpdatingPauseTimePercent=5 + +## Main G1GC tunable: lowering the pause target will lower throughput and vise versa. +## 200ms is the JVM default and lowest viable setting +## 1000ms increases throughput. Keep it smaller than the timeouts. +set JAVA_OPTS=%JAVA_OPTS% -XX:MaxGCPauseMillis=500 + +## Optional G1 Settings + +# Save CPU time on large (>= 16GB) heaps by delaying region scanning +# until the heap is 70% full. The default in Hotspot 8u40 is 40%. +#set JAVA_OPTS=%JAVA_OPTS% -XX:InitiatingHeapOccupancyPercent=70 + +# For systems with > 8 cores, the default ParallelGCThreads is 5/8 the number of logical cores. +# Otherwise equal to the number of cores when 8 or less. +# Machines with > 10 cores should try setting these to <= full cores. +#set JAVA_OPTS=%JAVA_OPTS% -XX:ParallelGCThreads=16 + +# By default, ConcGCThreads is 1/4 of ParallelGCThreads. +# Setting both to the same value can reduce STW durations. +#set JAVA_OPTS=%JAVA_OPTS% -XX:ConcGCThreads=16 + +### GC logging options -- uncomment to enable + +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDateStamps +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintHeapAtGC +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime +set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintPromotionFailure +#set JAVA_OPTS=%JAVA_OPTS% -XX:PrintFLSStatistics=1 +#set JAVA_OPTS=%JAVA_OPTS% -Xloggc:/var/log/moquette/gc.log +set JAVA_OPTS=%JAVA_OPTS% -XX:+UseGCLogFileRotation +set JAVA_OPTS=%JAVA_OPTS% -XX:NumberOfGCLogFiles=10 +set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M" + +%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dmoquette.path=%MOQUETTE_PATH% -cp %MOQUETTE_HOME%\lib\* io.moquette.server.Server diff --git a/distribution/src/main/scripts/moquette.sh b/distribution/src/main/scripts/moquette.sh index c034019c..7431e11d 100644 --- a/distribution/src/main/scripts/moquette.sh +++ b/distribution/src/main/scripts/moquette.sh @@ -12,9 +12,8 @@ echo " | | | | (_) | (_| | |_| | __/ |_| || __/ | | | \ \/' / | | | | " echo " \_| |_/\___/ \__, |\__,_|\___|\__|\__\___| \_| |_/\_/\_\ \_/ \_/ " echo " | | " echo " |_| " -echo " " - - +echo " " + cd "$(dirname "$0")" @@ -52,5 +51,45 @@ MOQUETTE_PATH=$MOQUETTE_HOME/ #LOG_FILE_LEVEL=fine JAVA_OPTS_SCRIPT="-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true" -$JAVA -server $JAVA_OPTS $JAVA_OPTS_SCRIPT -Dlog4j.configuration="file:$LOG_FILE" -Dmoquette.path="$MOQUETTE_PATH" -cp "$MOQUETTE_HOME/lib/*" io.moquette.server.Server +## Use the Hotspot garbage-first collector. +JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC" +## Have the JVM do less remembered set work during STW, instead +## preferring concurrent GC. Reduces p99.9 latency. +JAVA_OPTS="$JAVA_OPTS -XX:G1RSetUpdatingPauseTimePercent=5" + +## Main G1GC tunable: lowering the pause target will lower throughput and vise versa. +## 200ms is the JVM default and lowest viable setting +## 1000ms increases throughput. Keep it smaller than the timeouts. +JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=500" + +## Optional G1 Settings + +# Save CPU time on large (>= 16GB) heaps by delaying region scanning +# until the heap is 70% full. The default in Hotspot 8u40 is 40%. +#JAVA_OPTS="$JAVA_OPTS -XX:InitiatingHeapOccupancyPercent=70" + +# For systems with > 8 cores, the default ParallelGCThreads is 5/8 the number of logical cores. +# Otherwise equal to the number of cores when 8 or less. +# Machines with > 10 cores should try setting these to <= full cores. +#JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=16" + +# By default, ConcGCThreads is 1/4 of ParallelGCThreads. +# Setting both to the same value can reduce STW durations. +#JAVA_OPTS="$JAVA_OPTS -XX:ConcGCThreads=16" + +### GC logging options -- uncomment to enable + +JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails" +JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps" +JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC" +JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution" +JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime" +JAVA_OPTS="$JAVA_OPTS -XX:+PrintPromotionFailure" +#JAVA_OPTS="$JAVA_OPTS -XX:PrintFLSStatistics=1" +#JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/moquette/gc.log" +JAVA_OPTS="$JAVA_OPTS -XX:+UseGCLogFileRotation" +JAVA_OPTS="$JAVA_OPTS -XX:NumberOfGCLogFiles=10" +JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M" + +$JAVA -server $JAVA_OPTS $JAVA_OPTS_SCRIPT -Dlog4j.configuration="file:$LOG_FILE" -Dmoquette.path="$MOQUETTE_PATH" -cp "$MOQUETTE_HOME/lib/*" io.moquette.server.Server