Skip to content

Commit 3cd0383

Browse files
committed
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
1 parent 2d6b869 commit 3cd0383

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ PHP NEWS
111111
. Added mysqlnd.collect_memory_statistics to ini quick reference.
112112
(hauk92)
113113

114-
- OPcache:
114+
- Opcache:
115115
. Fixed ZTS OPcache build on Cygwin. (cmb)
116116
. Added opcache.file_cache_read_only. (Samuel Melrose)
117+
. Updated default value of opcache.jit_hot_loop. (Arnaud)
117118

118119
- Output:
119120
. Fixed calculation of aligned buffer size. (cmb)

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ PHP 8.5 UPGRADE NOTES
460460
Note: A cache generated with a different build of PHP, a different file
461461
path, or different settings (including which extensions are loaded), may be
462462
ignored.
463+
. The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it
464+
from being a multiple of loop iteration counts.
465+
It is recommended that this parameter is set to a prime number.
463466

464467
========================================
465468
12. Windows Support

ext/opcache/zend_accelerator_module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ ZEND_INI_BEGIN()
323323
STD_PHP_INI_ENTRY("opcache.jit_max_root_traces" , "1024", PHP_INI_SYSTEM, OnUpdateLong, max_root_traces, zend_jit_globals, jit_globals)
324324
STD_PHP_INI_ENTRY("opcache.jit_max_side_traces" , "128", PHP_INI_SYSTEM, OnUpdateLong, max_side_traces, zend_jit_globals, jit_globals)
325325
STD_PHP_INI_ENTRY("opcache.jit_max_exit_counters" , "8192", PHP_INI_SYSTEM, OnUpdateLong, max_exit_counters, zend_jit_globals, jit_globals)
326-
STD_PHP_INI_ENTRY("opcache.jit_hot_loop" , "64", PHP_INI_SYSTEM, OnUpdateCounter, hot_loop, zend_jit_globals, jit_globals)
326+
/* Defautl value should be a prime number, to reduce the chances of loop iterations being a factor of opcache.jit_hot_loop */
327+
STD_PHP_INI_ENTRY("opcache.jit_hot_loop" , "61", PHP_INI_SYSTEM, OnUpdateCounter, hot_loop, zend_jit_globals, jit_globals)
327328
STD_PHP_INI_ENTRY("opcache.jit_hot_func" , "127", PHP_INI_SYSTEM, OnUpdateCounter, hot_func, zend_jit_globals, jit_globals)
328329
STD_PHP_INI_ENTRY("opcache.jit_hot_return" , "8", PHP_INI_SYSTEM, OnUpdateCounter, hot_return, zend_jit_globals, jit_globals)
329330
STD_PHP_INI_ENTRY("opcache.jit_hot_side_exit" , "8", PHP_INI_ALL, OnUpdateCounter, hot_side_exit, zend_jit_globals, jit_globals)

0 commit comments

Comments
 (0)