feat(fpm-tune): expose cpu_ceiling + cpu_headroom in the embedded runtime - #142
Merged
Conversation
…untime The tuner sizes pools to the memory budget; on CPU-bound workloads that oversubscribes the CPU and costs throughput. Benchmarked on a 2-CPU / 1 GiB container running a pure-CPU request (6k chained sha256 rounds), worker count vs throughput is monotonic downward: workers 2 4 6 8 12 21 rps 403 394 383 370 311 310 The memory budget allowed 21 workers (310 rps); the CPU fill with fpm-tune's default 2.0 headroom picks 4 (394 rps, +27%). fpm-tune has always had the mechanism - the standalone --cpu flag and serve.Config.CPUCeiling/CPUHeadroom - but the embedded runtime never mapped it. Now: fpm_tune.cpu_ceiling (bool) and fpm_tune.cpu_headroom (float, 0 = fpm-tune default 2.0), env-overridable via the generic CBOX_INIT_GLOBAL_FPM_TUNE_CPU_CEILING / _CPU_HEADROOM path, negative headroom rejected by validation. Example config documents the trade.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The embedded tuner sizes pools to the memory budget. On CPU-bound workloads that oversubscribes the CPU: on a 2-CPU/1 GiB container running a pure-CPU request (6k chained sha256 rounds,
wrk -t4 -c64), throughput falls monotonically with worker count —The memory budget picked 21 workers (310 rps). The CPU fill × fpm-tune's default 2.0 headroom picks 4 (394 rps, +27%).
fpm-tune has always had the mechanism (standalone
--cpu,serve.Config.CPUCeiling/CPUHeadroom) — the embedded runtime just never mapped it. This addsfpm_tune.cpu_ceiling+fpm_tune.cpu_headroom(0 = default 2.0), automatically env-overridable asCBOX_INIT_GLOBAL_FPM_TUNE_CPU_CEILING/_CPU_HEADROOM, with validation (negative headroom rejected) and tests for yaml load, env override, and rejection. Example config documents the trade-off.Verified end-to-end in the php-baseimages benchmark harness: an image with this build,
CBOX_FPM_TUNE=true+CBOX_INIT_GLOBAL_FPM_TUNE_CPU_CEILING=true, converges to the CPU-sized pool at runtime. Gate: full tests, vet, gofmt, golangci-lint v2.12.2 0 issues.