diff --git a/README.md b/README.md index 725c957..2a60c8f 100644 --- a/README.md +++ b/README.md @@ -38,27 +38,28 @@ 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/.ini`) | -| `SERVER_PASSWORD` | | Password clients need to join (`.ini` `Password`) | -| `PUBLIC` | | `true`/`false`: listed in the in-game server browser | -| `PUBLIC_NAME` | | Name in the server browser | -| `PORT` | `16261` | Game port (`-port`) | -| `UDP_PORT` | `16262` | Direct connection port (`-udpport`) | -| `UPNP` | | `true`/`false`: UPnP port mapping on the router (`.ini` `UPnP`); `false` recommended (see below) | -| `ADMIN_USERNAME` | `admin` | First start only | -| `ADMIN_PASSWORD` | | Required on the first start, ignored afterwards | -| `SERVER_PRESET` | | Sandbox preset for a new server: `Apocalypse`, `Extinction`, `Outbreak`, `Rising`, `SixMonthsLater` | -| `MODS` | | Mod IDs, Build 42 format: `\ModA;\ModB` | -| `WORKSHOP_ITEMS` | | Workshop item IDs: `123;456` | -| `RCON_PASSWORD` | | Written into the `.ini` on every start; RCON is disabled without it | -| `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`) | -| `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` | +| Variable | Default | | +|--------------------------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| `SERVER_NAME` | `zomboidforge` | Server config name (`/data/Server/.ini`) | +| `SERVER_PASSWORD` | | Password clients need to join (`.ini` `Password`) | +| `PUBLIC` | | `true`/`false`: listed in the in-game server browser | +| `PUBLIC_NAME` | | Name in the server browser | +| `PORT` | `16261` | Game port (`-port`) | +| `UDP_PORT` | `16262` | Direct connection port (`-udpport`) | +| `UPNP` | | `true`/`false`: UPnP port mapping on the router (`.ini` `UPnP`); `false` recommended (see below) | +| `ADMIN_USERNAME` | `admin` | First start only | +| `ADMIN_PASSWORD` | | Required on the first start, ignored afterwards | +| `SERVER_PRESET` | | Sandbox preset for a new server: `Apocalypse`, `Extinction`, `Outbreak`, `Rising`, `SixMonthsLater` | +| `MODS` | | Mod IDs, Build 42 format: `\ModA;\ModB` | +| `WORKSHOP_ITEMS` | | Workshop item IDs: `123;456` | +| `RCON_PASSWORD` | | Written into the `.ini` on every start; RCON is disabled without it | +| `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` | Notes: @@ -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`). diff --git a/compose.yaml b/compose.yaml index 9c52511..b9ca7cf 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,23 +6,24 @@ services: image: localhost/zomboidforge:dev platform: linux/amd64 environment: - SERVER_NAME: ${SERVER_NAME:-zomboidforgetest} - SERVER_PASSWORD: ${SERVER_PASSWORD:-} - PUBLIC: ${PUBLIC:-} - PUBLIC_NAME: ${PUBLIC_NAME:-} - PORT: ${PORT:-16261} - UDP_PORT: ${UDP_PORT:-16262} - ADMIN_USERNAME: ${ADMIN_USERNAME:-} - ADMIN_PASSWORD: ${ADMIN_PASSWORD:-} - SERVER_PRESET: ${SERVER_PRESET:-} - MODS: ${MODS:-} - WORKSHOP_ITEMS: ${WORKSHOP_ITEMS:-} - RCON_PASSWORD: ${RCON_PASSWORD:-} - UPNP: ${UPNP:-} - JVM_MIN_HEAP: ${JVM_MIN_HEAP:-} - JVM_MAX_HEAP: ${JVM_MAX_HEAP:-} - JVM_UNCOMMIT_DELAY: ${JVM_UNCOMMIT_DELAY:-} - ZF_EXPERIMENTAL_PERFORMANCE: ${ZF_EXPERIMENTAL_PERFORMANCE:-} + SERVER_NAME: ${SERVER_NAME:-zomboidforgetest} + SERVER_PASSWORD: ${SERVER_PASSWORD:-} + PUBLIC: ${PUBLIC:-} + PUBLIC_NAME: ${PUBLIC_NAME:-} + PORT: ${PORT:-16261} + UDP_PORT: ${UDP_PORT:-16262} + ADMIN_USERNAME: ${ADMIN_USERNAME:-} + ADMIN_PASSWORD: ${ADMIN_PASSWORD:-} + SERVER_PRESET: ${SERVER_PRESET:-} + MODS: ${MODS:-} + WORKSHOP_ITEMS: ${WORKSHOP_ITEMS:-} + RCON_PASSWORD: ${RCON_PASSWORD:-} + UPNP: ${UPNP:-} + 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 # to Steam and to clients, so a remapped port is unreachable. diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 292300e..5ec565d 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -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")