Skip to content

Commit

Permalink
chore(dist): replace G1 config & handle other gc options (#2664)
Browse files Browse the repository at this point in the history
  • Loading branch information
MingzhenHan authored Oct 10, 2024
1 parent 861a100 commit 29ecc04
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,20 @@ fi

# Using G1GC as the default garbage collector (Recommended for large memory machines)
case "$GC_OPTION" in
g1)
"")
echo "Using G1GC as the default garbage collector"
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+ParallelRefProcEnabled \
-XX:InitiatingHeapOccupancyPercent=50 -XX:G1RSetUpdatingPauseTimePercent=5"
;;
"") ;;
zgc|ZGC)
echo "Using ZGC as the default garbage collector (Only support Java 11+)"
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \
-XX:ConcGCThreads=2 -XX:ParallelGCThreads=6 \
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive"
;;
*)
echo "Unrecognized gc option: '$GC_OPTION', only support 'g1' now" >> ${OUTPUT}
echo "Unrecognized gc option: '$GC_OPTION', default use g1, options only support 'ZGC' now" >> ${OUTPUT}
exit 1
esac

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ fi
# Using G1GC as the default garbage collector (Recommended for large memory machines)
# mention: zgc is only available on ARM-Mac with java > 13
case "$GC_OPTION" in
g1|G1|g1gc)
"")
echo "Using G1GC as the default garbage collector"
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+ParallelRefProcEnabled \
-XX:InitiatingHeapOccupancyPercent=50 \
-XX:G1RSetUpdatingPauseTimePercent=5"
;;
Expand All @@ -134,9 +134,8 @@ case "$GC_OPTION" in
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive"
;;
"") ;;
*)
echo "Unrecognized gc option: '$GC_OPTION', only support 'G1/ZGC' now" >> ${OUTPUT}
echo "Unrecognized gc option: '$GC_OPTION', default use g1, options only support 'ZGC' now" >> ${OUTPUT}
exit 1
esac

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if [ "$JAVA_OPTIONS" = "" ]; then
>> ${OUTPUT}
exit 1
fi
JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:MetaspaceSize=256M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION} "
JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:MetaspaceSize=256M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION} "
# JAVA_OPTIONS="-Xms${MIN_MEM}m -Xmx${XMX}m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOGS} ${USER_OPTION}"

# Rolling out detailed GC logs
Expand All @@ -153,14 +153,20 @@ fi

# Using G1GC as the default garbage collector (Recommended for large memory machines)
case "$GC_OPTION" in
g1)
"")
echo "Using G1GC as the default garbage collector"
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+ParallelRefProcEnabled \
-XX:InitiatingHeapOccupancyPercent=50 -XX:G1RSetUpdatingPauseTimePercent=5"
;;
"") ;;
zgc|ZGC)
echo "Using ZGC as the default garbage collector (Only support Java 11+)"
JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \
-XX:ConcGCThreads=2 -XX:ParallelGCThreads=6 \
-XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \
-XX:+UnlockDiagnosticVMOptions -XX:-ZProactive"
;;
*)
echo "Unrecognized gc option: '$GC_OPTION', only support 'g1' now" >> ${OUTPUT}
echo "Unrecognized gc option: '$GC_OPTION', default use g1, options only support 'ZGC' now" >> ${OUTPUT}
exit 1
esac

Expand Down

0 comments on commit 29ecc04

Please sign in to comment.