Disable JIT by default, make it opt-in via --force-jit#1
Open
Disable JIT by default, make it opt-in via --force-jit#1
Conversation
Benchmarks across multiple platforms (Windows, Linux, macOS) and codebases consistently show JIT hurting Psalm performance by 5-35%. Additionally, JIT causes segfaults during taint analysis on certain platforms due to PHP core JIT bugs. Split opcache settings into base (always applied) and JIT-specific (only applied when --force-jit or forceJit="true" is set). This keeps opcache optimizations while avoiding JIT overhead and instability by default. Refs vimeo#11589, vimeo#11613
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.
Summary
Disable JIT by default and make it opt-in via the existing
--force-jitflag /forceJitconfig option.Recent PHP JIT changes (bug fixes and refactors that increased compilation times) have shifted the performance tradeoff — as confirmed by @danog's own benchmarks in vimeo#11589. Additionally, JIT causes segfaults (exit code 139) during taint analysis on certain platforms due to PHP core JIT bugs (php/php-src#17858, php/php-src#13180).
Changes
PsalmRestarter: SplitREQUIRED_OPCACHE_SETTINGSinto base opcache settings (always applied) andJIT_OPCACHE_SETTINGS(only applied whenenableJitis true)Psalm.php: PassforceJitto the restarter; JIT status messages only shown when--force-jitis setforceJitdescription to reflect it now enables JIT rather than just guarding availabilityWhat stays the same
--force-jit/forceJit="true"works exactly as before for users who want JITforceJitnaturally becomes the opt-inDX
Default
psalmjust works — no JIT overhead, no segfaults, no misleading messages. Users who want JIT explicitly opt in.Related PRs
forceJitis enabled vimeo/psalm#11613 (@theodorejb) — the original proposal to make JIT opt-in. This PR builds on that idea with cleaner separation of opcache/JIT settings and simpler DX.Open for discussion
This is a PoC — the default behavior is open for discussion. For example, instead of a simple on/off,
forceJitcould support three modes:auto(default) — enable JIT when available, fall back gracefully if noton— always enable JIT, exit if unavailable (current--force-jitbehavior)off— never enable JITHappy to iterate on the approach.