From 20604dd79cc9b4d0ce1557fd71a50b93a75551ae Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 9 May 2026 11:06:59 +0200 Subject: [PATCH] docs(deploy): document CPU isolation in performance-tuning section Explains the core-0-vs-game-cores split, the LEFT4ME_SYSTEM_CPUS / LEFT4ME_GAME_CPUS overrides, the single-core skip, and the subset-of relationship with per-instance CPUAffinity=. Co-Authored-By: Claude Opus 4.7 (1M context) --- deploy/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deploy/README.md b/deploy/README.md index 37f1575..7807bcf 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -90,6 +90,20 @@ Install via `sudo apt install linux-cpupower` if the binary isn't present. Persist via your distro's CPU-frequency tooling (e.g. `/etc/default/cpufrequtils`). +### CPU isolation (cores) + +The deploy script writes four `AllowedCPUs=` drop-ins so that, by default, only `l4d2-game.slice` is allowed to run on cores 1..N-1; `system.slice`, `user.slice`, and `l4d2-build.slice` are pinned to core 0. Game servers thus get the host minus core 0 exclusively, the build sandbox and the web app stay on core 0, and a logged-in admin running CPU-heavy work in their shell can't steal cycles from a live match. + +Override the split by setting either env var when running the deploy: + +```sh +LEFT4ME_SYSTEM_CPUS="0,1" LEFT4ME_GAME_CPUS="2-7" deploy/deploy-test-server.sh deploy-user@host +``` + +On single-core hosts the deploy skips the cpuset drop-ins entirely and prints a warning to stderr; the rest of the perf baseline (cgroup weights, sysctls, OOM scores) still applies. To force isolation on a single-core host anyway (rarely useful), set either env var explicitly. + +Per-instance `CPUAffinity=` (next subsection) composes on top of this — the per-instance value must be a subset of `l4d2-game.slice`'s `AllowedCPUs=`, which the kernel enforces. + ### Per-instance CPU affinity `srcds` is single-threaded per instance. On a multi-core host, pinning each instance to its own core can cut jitter under contention. Drop in `/etc/systemd/system/left4me-server@.service.d/affinity.conf`: