Adjust default value of opcache.jit_hot_loop to a prime number

Loops whose number of iterations + 1 is a factor of opcache.jit_hot_loop
will always be traced at the exact moment the loop condition evaluates
to false. As a result, these loops can never be JIT'ed successfully.

Here I adjust the default value of opcache.jit_hot_loop to a prime number,
so this can not happen (unless number of iterations+1 is opcache.jit_hot_loop).

Closes GH-18573
This commit is contained in:
Arnaud Le Blanc 2025-05-16 18:05:11 +02:00
parent 2d6b86945f
commit 3cd0383d91
No known key found for this signature in database
3 changed files with 7 additions and 2 deletions

3
NEWS
View file

@ -111,9 +111,10 @@ PHP NEWS
. Added mysqlnd.collect_memory_statistics to ini quick reference. . Added mysqlnd.collect_memory_statistics to ini quick reference.
(hauk92) (hauk92)
- OPcache: - Opcache:
. Fixed ZTS OPcache build on Cygwin. (cmb) . Fixed ZTS OPcache build on Cygwin. (cmb)
. Added opcache.file_cache_read_only. (Samuel Melrose) . Added opcache.file_cache_read_only. (Samuel Melrose)
. Updated default value of opcache.jit_hot_loop. (Arnaud)
- Output: - Output:
. Fixed calculation of aligned buffer size. (cmb) . Fixed calculation of aligned buffer size. (cmb)

View file

@ -460,6 +460,9 @@ PHP 8.5 UPGRADE NOTES
Note: A cache generated with a different build of PHP, a different file Note: A cache generated with a different build of PHP, a different file
path, or different settings (including which extensions are loaded), may be path, or different settings (including which extensions are loaded), may be
ignored. ignored.
. The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it
from being a multiple of loop iteration counts.
It is recommended that this parameter is set to a prime number.
======================================== ========================================
12. Windows Support 12. Windows Support

View file

@ -323,7 +323,8 @@ ZEND_INI_BEGIN()
STD_PHP_INI_ENTRY("opcache.jit_max_root_traces" , "1024", PHP_INI_SYSTEM, OnUpdateLong, max_root_traces, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_max_root_traces" , "1024", PHP_INI_SYSTEM, OnUpdateLong, max_root_traces, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_max_side_traces" , "128", PHP_INI_SYSTEM, OnUpdateLong, max_side_traces, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_max_side_traces" , "128", PHP_INI_SYSTEM, OnUpdateLong, max_side_traces, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_max_exit_counters" , "8192", PHP_INI_SYSTEM, OnUpdateLong, max_exit_counters, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_max_exit_counters" , "8192", PHP_INI_SYSTEM, OnUpdateLong, max_exit_counters, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_hot_loop" , "64", PHP_INI_SYSTEM, OnUpdateCounter, hot_loop, zend_jit_globals, jit_globals) /* Defautl value should be a prime number, to reduce the chances of loop iterations being a factor of opcache.jit_hot_loop */
STD_PHP_INI_ENTRY("opcache.jit_hot_loop" , "61", PHP_INI_SYSTEM, OnUpdateCounter, hot_loop, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_hot_func" , "127", PHP_INI_SYSTEM, OnUpdateCounter, hot_func, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_hot_func" , "127", PHP_INI_SYSTEM, OnUpdateCounter, hot_func, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_hot_return" , "8", PHP_INI_SYSTEM, OnUpdateCounter, hot_return, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_hot_return" , "8", PHP_INI_SYSTEM, OnUpdateCounter, hot_return, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_hot_side_exit" , "8", PHP_INI_ALL, OnUpdateCounter, hot_side_exit, zend_jit_globals, jit_globals) STD_PHP_INI_ENTRY("opcache.jit_hot_side_exit" , "8", PHP_INI_ALL, OnUpdateCounter, hot_side_exit, zend_jit_globals, jit_globals)