Add JVM_EXPERIMENTAL_PERFORMANCE configuration to enable compact object headers and transparent huge pages in the JVM.

This commit is contained in:
Overlord committed 2026-10-07 07:57:17 +02:00
1 parent 49af536786
commit be08756c36
3 files changed
+20 -1

No files matched your search

+5 -1
View File
@@ -39,7 +39,7 @@ podman run -d --name zomboidforge \
Unset variables keep the value in the server `.ini` (or the game default).
| Variable | Default | |
|-------------------------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|--------------------------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `SERVER_NAME` | `zomboidforge` | Server config name (`/data/Server/<name>.ini`) |
| `SERVER_PASSWORD` | | Password clients need to join (`.ini` `Password`) |
| `PUBLIC` | | `true`/`false`: listed in the in-game server browser |
@@ -56,6 +56,7 @@ Unset variables keep the value in the server `.ini` (or the game default).
| `JVM_MIN_HEAP` | JVM default | `-Xms`; unused heap memory is returned to the system only down to this size |
| `JVM_MAX_HEAP` | 75 % of the memory limit | `-Xmx`; `8g` when the container has no memory limit |
| `JVM_UNCOMMIT_DELAY` | `60` | Seconds after which unused heap memory is returned to the system (`-XX:ZUncommitDelay`) |
| `JVM_EXPERIMENTAL_PERFORMANCE` | `false` | `true`/`false`: `-XX:+UseCompactObjectHeaders` and `-XX:+UseTransparentHugePages` (see below) |
| `STEAM` | `1` | `0` runs the server without Steam |
| `SOFT_RESET` | | `true` starts once in soft reset mode (`-Dsoftreset`); unset it afterwards |
| `ZF_EXPERIMENTAL_PERFORMANCE` | `false` | `true`/`false`: performance changes that alter timing or resource use (more threads, shorter waits); overrides `forge.toml` |
@@ -76,6 +77,9 @@ Notes:
rest stays for native memory. The startup briefly needs a large heap; with 8 players
exploring, the heap held up to 4.4 GB of live data in tests. A limit below about 6 GB is
not recommended. Without a limit the heap is `8g`, as in vanilla.
- **Huge pages:** `JVM_EXPERIMENTAL_PERFORMANCE=true` maps the heap with transparent huge pages
only when the host's `/sys/kernel/mm/transparent_hugepage/shmem_enabled` is `advise` or
`always` (a container cannot change it); otherwise the JVM logs a warning and runs without them.
- **Stopping:** `SIGTERM` triggers the game's own save-and-quit. Allow enough time for large worlds.
For local testing use `compose.yaml` (`podman compose up --build`, settings from `.env`).
+1
View File
@@ -22,6 +22,7 @@ services:
JVM_MIN_HEAP: ${JVM_MIN_HEAP:-}
JVM_MAX_HEAP: ${JVM_MAX_HEAP:-}
JVM_UNCOMMIT_DELAY: ${JVM_UNCOMMIT_DELAY:-}
JVM_EXPERIMENTAL_PERFORMANCE: ${JVM_EXPERIMENTAL_PERFORMANCE:-}
ZF_EXPERIMENTAL_PERFORMANCE: ${ZF_EXPERIMENTAL_PERFORMANCE:-}
ports:
# Host and container ports must be equal: the server reports its own port
+14
View File
@@ -45,6 +45,12 @@
# JVM_UNCOMMIT_DELAY
# Seconds of disuse after which ZGC returns heap memory to the system
# (-XX:ZUncommitDelay). Default: 60 (JVM default: 300)
# JVM_EXPERIMENTAL_PERFORMANCE
# true/false: compact object headers (-XX:+UseCompactObjectHeaders) and
# transparent huge pages for the heap (-XX:+UseTransparentHugePages).
# Huge pages need the host's
# /sys/kernel/mm/transparent_hugepage/shmem_enabled at advise or always;
# otherwise the JVM logs a warning and runs without them. Default: false
#
# Maintenance
# SOFT_RESET true: start in Project Zomboid's soft reset mode (-Dsoftreset).
@@ -83,6 +89,7 @@ readonly RCON_PASSWORD="${RCON_PASSWORD:-}"
readonly JVM_MIN_HEAP="${JVM_MIN_HEAP:-}"
readonly JVM_MAX_HEAP="${JVM_MAX_HEAP:-}"
readonly JVM_UNCOMMIT_DELAY="${JVM_UNCOMMIT_DELAY:-60}"
readonly JVM_EXPERIMENTAL_PERFORMANCE="${JVM_EXPERIMENTAL_PERFORMANCE:-}"
readonly SOFT_RESET="${SOFT_RESET:-}"
readonly SERVER_INI="${DATA_DIR}/Server/${SERVER_NAME}.ini"
@@ -336,6 +343,13 @@ build_jvm_args() {
if [[ -n "${JVM_MIN_HEAP}" ]]; then
jvm_args+=("-Xms${JVM_MIN_HEAP}")
fi
if [[ -n "${JVM_EXPERIMENTAL_PERFORMANCE}" ]]; then
if is_true "${JVM_EXPERIMENTAL_PERFORMANCE}"; then
jvm_args+=("-XX:+UseCompactObjectHeaders" "-XX:+UseTransparentHugePages")
elif ! is_false "${JVM_EXPERIMENTAL_PERFORMANCE}"; then
fail "JVM_EXPERIMENTAL_PERFORMANCE must be true or false, got '${JVM_EXPERIMENTAL_PERFORMANCE}'."
fi
fi
if [[ -n "${SOFT_RESET}" ]] && is_true "${SOFT_RESET}"; then
log "SOFT_RESET is set: starting in soft reset mode. Unset it for the next start."
jvm_args+=("-Dsoftreset")