fix(autotune): clamp instead of killing PID 1 when a profile does not fit (#133) - #134
Merged
Merged
Conversation
… fit (#133) The boot PHP-FPM calculator exited PID 1 when the container's memory limit could not fit the selected profile, so any image with a baked default profile (for example PHP_FPM_AUTOTUNE_PROFILE=medium) crash-looped at boot below ~512MB. Since 3.1 the boot value is only the seed for the embedded runtime autotuner, so refusing to start is the wrong failure mode. The calculator now sizes through one shared memory model that clamps to the largest worker count that fits (down to one worker, over-committed with a loud warning on a pathologically small box) and boots, rather than erroring. A new global.autotune_strict (env PHP_FPM_AUTOTUNE_STRICT) keeps the fail-hard behaviour for operators who want a hard guarantee; its error names the profile and the smallest limit that runs it. The pre-check minimum and the sizing now share smallestBootableLimit, so the reported minimum is a limit that actually boots (the two used to disagree, which made the refusal message confusing). Verified end to end: a --memory=256m medium container boots (clamped) instead of exiting 1, and fails clearly under strict mode. Closes #133
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.
Fixes #133 — the boot PHP-FPM calculator exited PID 1 when the memory limit could not fit the profile, crash-looping any image with a baked default profile (e.g.
PHP_FPM_AUTOTUNE_PROFILE=medium) below ~512MB.Change
sizeWorkers) picks the largest worker count that fits; the profile minimum is now a preference, not a hard floor that can OOM. Too small → clamp (down to 1 worker, over-committed with a loud WARN) and boot.Calculate()errors only in strict mode.global.autotune_strict(envPHP_FPM_AUTOTUNE_STRICT), default false. True keeps fail-hard, with a message naming the profile and the smallest limit that runs it.smallestBootableLimit): the pre-check number equals a limit that actually boots (they used to disagree).validateConfig(sizing owns memory now).Acceptance criteria (#133)
os.Exit(1)autotune_stricttoggle, documentedVerified
Full gate green (fmt, vet, lint, race tests, updated + new clamp/strict unit tests). End-to-end in a
php:8.4-fpmcontainer:--memory=256m+medium(the crash-loop case): boots, clamped to 1 worker,/proc/1/comm= cbox-init.PHP_FPM_AUTOTUNE_STRICT=1: exits 1 withprofile "Medium Production" needs at least 488MB for its 4-worker minimum, but the limit is 256MB; ... set global.autotune_strict: false to clamp and boot.