mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-11-07 17:29:21 +00:00
Add USE_MEOWICE_ZGC_FLAGS to use the ZGC version of MeowIce's flags (#4382)
This commit is contained in:
1 parent
31ab4db856
commit
e894a1d394
3 files changed
+43
-4
No files matched your search
@@ -158,3 +158,5 @@ When `MEMORY` is greater than or equal to 12G, then the Aikar flags will be adju
|
||||
[MeowIce has created an updated set of JVM flags](https://github.com/MeowIce/meowice-flags?tab=readme-ov-file#why-would-i-have-to-switch-) based on Aikar's flags but with support for optimizations for Java 17 and above
|
||||
|
||||
The set of flags documented there can be added by setting the environment variable `USE_MEOWICE_FLAGS` to `true`. There is an optional `USE_MEOWICE_GRAALVM_FLAGS` variable to enable GraalVM specific optimizations, defaults to `FALSE`.
|
||||
|
||||
MeowIce's flags use the G1 garbage collector by default. MeowIce also provides a [ZGC version of the flags](https://github.com/MeowIce/meowice-flags#zgc-version-for-large-servers-with-32gb-allocated-heap), which is recommended for servers with 32GB or more of allocated memory and many CPU cores. To use it instead, also set `USE_MEOWICE_ZGC_FLAGS` to `true`. When `MAX_MEMORY` (or `MEMORY`) is larger than 2GB, the soft max heap size is set to 2GB below it, as in MeowIce's flags.
|
||||
@@ -129,6 +129,12 @@ alternatively, you can mount: <code>/etc/localtime:/etc/localtime:ro
|
||||
<td><code>true</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>USE_MEOWICE_ZGC_FLAGS</code></td>
|
||||
<td>uses the ZGC version of MeowIce's flags instead of the G1 version when USE_MEOWICE_FLAGS is also TRUE</td>
|
||||
<td><code>false</code></td>
|
||||
<td>⬜️</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>JVM_OPTS</code></td>
|
||||
<td>General JVM options can be passed to the Minecraft Server invocation by passing a <code>JVM_OPTS</code> environment variable. The JVM requires -XX options to precede -X options, so those can be declared in <code>JVM_XX_OPTS</code>. Both variables are space-delimited, raw JVM arguments</td>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
: "${USE_AIKAR_FLAGS:=false}"
|
||||
: "${USE_MEOWICE_FLAGS:=false}"
|
||||
: "${USE_MEOWICE_GRAALVM_FLAGS:=false}"
|
||||
: "${USE_MEOWICE_ZGC_FLAGS:=false}"
|
||||
|
||||
if isTrue "${USE_MEOWICE_FLAGS}" || isTrue "${USE_MEOWICE_GRAALVM_FLAGS}"; then
|
||||
java_major_version=$(mc-image-helper java-release)
|
||||
@@ -18,7 +19,29 @@ if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if isTrue "${USE_AIKAR_FLAGS}" || isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
use_meowice_zgc=false
|
||||
if isTrue "${USE_MEOWICE_FLAGS}" && isTrue "${USE_MEOWICE_ZGC_FLAGS}"; then
|
||||
use_meowice_zgc=true
|
||||
fi
|
||||
|
||||
if isTrue "${use_meowice_zgc}"; then
|
||||
log "Using MeowIce's ZGC flags"
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UseZGC
|
||||
-XX:-ZProactive
|
||||
-XX:+UnlockExperimentalVMOptions
|
||||
-XX:+DisableExplicitGC
|
||||
-XX:+AlwaysPreTouch
|
||||
-XX:+PerfDisableSharedMem
|
||||
"
|
||||
# MeowIce sets the soft max heap size to 2GB below the max heap size
|
||||
if [[ $MAX_MEMORY ]] && max_memory_bytes=$(normalizeMemSize "${MAX_MEMORY}") \
|
||||
&& (( max_memory_bytes > $(normalizeMemSize 2048m) )); then
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:SoftMaxHeapSize=$(( max_memory_bytes / 1048576 - 2048 ))M
|
||||
"
|
||||
fi
|
||||
elif isTrue "${USE_AIKAR_FLAGS}" || isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
# From https://mcflags.emc.gs/
|
||||
if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
log "Using MeowIce's flags"
|
||||
@@ -81,8 +104,6 @@ if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UnlockDiagnosticVMOptions
|
||||
-XX:+UnlockExperimentalVMOptions
|
||||
-XX:G1SATBBufferEnqueueingThresholdPercent=30
|
||||
-XX:G1ConcMarkStepDurationMillis=5
|
||||
-XX:+UseNUMA
|
||||
-XX:-DontCompileHugeMethods
|
||||
-XX:MaxNodeLimit=240000
|
||||
@@ -94,7 +115,6 @@ if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
-XX:NmethodSweepActivity=1
|
||||
-XX:+UseFastUnorderedTimeStamps
|
||||
-XX:+UseCriticalJavaThreadPriority
|
||||
-XX:AllocatePrefetchStyle=3
|
||||
-XX:+AlwaysActAsServerClassMachine
|
||||
-XX:+UseTransparentHugePages
|
||||
-XX:LargePageSizeInBytes=2M
|
||||
@@ -124,6 +144,17 @@ if isTrue "${USE_MEOWICE_FLAGS}"; then
|
||||
-XX:+UseCopySignIntrinsic
|
||||
-XX:+UseVectorStubs
|
||||
"
|
||||
if isTrue "${use_meowice_zgc}"; then
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:AllocatePrefetchStyle=1
|
||||
"
|
||||
else
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:G1SATBBufferEnqueueingThresholdPercent=30
|
||||
-XX:G1ConcMarkStepDurationMillis=5
|
||||
-XX:AllocatePrefetchStyle=3
|
||||
"
|
||||
fi
|
||||
if [[ $(arch) == "x86_64" ]]; then
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UseFastStosb
|
||||
|
||||
Reference in new issue
Block a user