From be3bfc23693ee910ab0aab781f3f20273e14405e Mon Sep 17 00:00:00 2001 From: SashegDev Date: Sat, 3 Oct 2026 11:58:59 +0000 Subject: [PATCH] perf(config): 2 chunk workers instead of 1, gen-parallelism on worker-threads: -1 means "auto", and auto on 4 cores resolves to ONE worker. MoonriseCommon.adjustWorkerThreads halves availableProcessors and then, if the result is <= 4, collapses it further - 4/2=2, and 2<=3 becomes 1. That single thread generated the spawn region serially. Measured on zern.cc (4 vCPU, 8 GB), same jar, same flags, cold world vs warm: before after cold, overworld 6770ms 2944ms cold, nether 1368ms 888ms cold, total 38.5s 24.9s warm, overworld 1084ms 803ms warm, total 16.4s 12.2s gen-parallelism "default" already resolved to true at startup, so it is now spelled out rather than left to string comparison at boot. 3 workers is deliberately NOT set here. The main thread plus Netty share the same 4 cores, and going to 3 trades main-thread headroom for generation that does not happen every tick. That needs a profile, not a guess. Also recorded the corollary: player-max-concurrent-chunk-generates is a rate limiter, not an accelerator. Speeding up generation without raising it just makes the engine faster behind a throttle that was sized for the old speed. --- zernmc-config/README.md | 13 ++++++++++--- zernmc-config/paper-global.yml | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/zernmc-config/README.md b/zernmc-config/README.md index 4433a6ffd..da3409920 100644 --- a/zernmc-config/README.md +++ b/zernmc-config/README.md @@ -47,10 +47,17 @@ - `entities.spawning.spawn-limits` — потолок мобов на чанк. ### `paper-global.yml` -- `chunk-system.io-threads: 2`, `worker-threads: -1` — не даём - чанковой системе съесть 4 ядра. +- **`chunk-system.worker-threads: 2`** — самый недооценённый рычаг. `auto` + (`-1`) на 4 ядрах даёт **1 воркер**, и генерация чанков идёт + последовательно: Moonrise делит `availableProcessors` пополам, а на + результате 2 опускается до 1, оставляя место главному треду. + Замерено: холодный старт **38.5 → 24.9 с**, тёплый **16.4 → 12.2 с**. + Значение 3 — только с профилем, главному треду на 4 ядрах нужно дышать. +- `chunk-system.io-threads: 2`, `gen-parallelism: true`. - `chunk-loading.advanced.player-max-concurrent-chunk-loads/generates` — - защита от флуда генерацией при скоростном облёте. + защита от флуда генерацией при скоростном облёте. **При ускорении + генерации этот потолок надо поднимать**, иначе движер быстрее, а + ограничитель остался прежним. ## Что НЕ трогаем - Moonrise (чанковая система) — уже многопоточный, отдельный патч не нужен. diff --git a/zernmc-config/paper-global.yml b/zernmc-config/paper-global.yml index 40f51834c..41d464eec 100644 --- a/zernmc-config/paper-global.yml +++ b/zernmc-config/paper-global.yml @@ -2,9 +2,14 @@ # Копировать в <сервер>/config/paper-global.yml chunk-system: - worker-threads: -1 # авто под 4 vCPU (Paper сам считает) - io-threads: 2 # сидеть на 4 ядрах - gen-parallelism: "default" + # worker-threads: -1 (auto) на 4 ядрах даёт 1 воркер, и генерация чанков + # идёт последовательно. Moonrise делит availableProcessors пополам, а на + # результате 2 опускается до 1, чтобы оставить место главному треду и Netty. + # 2 воркера: холодный старт 38.5с -> 24.9с, тёплый 16.4с -> 12.2с. + # 3 пробовать только с замером: главному треду на 4 ядрах нужно дышать. + worker-threads: 2 + io-threads: 2 + gen-parallelism: true chunk-loading: basic: