Skip to content

Commit 51d3a88

Browse files
authored
Improve opcache.max_accelerated_files validation (#22412)
* Improve opcache.max_accelerated_files validation
1 parent 40a8872 commit 51d3a88

7 files changed

Lines changed: 33 additions & 10 deletions

File tree

‎.github/workflows/test-suite.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ jobs:
480480
echo opcache.memory_consumption=256M >> /etc/php.d/opcache.ini
481481
echo opcache.file_update_protection=0 >> /etc/php.d/opcache.ini
482482
echo opcache.interned_strings_buffer=64 >> /etc/php.d/opcache.ini
483-
echo opcache.max_accelerated_files=100000 >> /etc/php.d/opcache.ini
483+
echo opcache.max_accelerated_files=130987 >> /etc/php.d/opcache.ini
484484
- name: Enable JIT
485485
if: ${{ matrix.type != 'verify_type_inference' }}
486486
run: |

‎UPGRADING‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ PHP 8.7 UPGRADE NOTES
153153
11. Changes to INI File Handling
154154
========================================
155155

156+
- Opcache:
157+
. opcache.max_accelerated_files now defaults to 16229 (previously 10000),
158+
accepts values up to 1048793 (previously 1000000), and logs a warning for
159+
values other than 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407,
160+
130987, 262237, 524521 and 1048793.
161+
156162
========================================
157163
12. Windows Support
158164
========================================

‎ext/opcache/tests/bug79665.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ string(1) "5"
2828
float(0.05)
2929
string(3) "128"
3030
int(134217728)
31-
string(5) "10000"
32-
int(10000)
31+
string(5) "16229"
32+
int(16229)

‎ext/opcache/zend_accelerator_module.c‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#define STRING_NOT_NULL(s) (NULL == (s)?"":s)
4343
#define MIN_ACCEL_FILES 200
44-
#define MAX_ACCEL_FILES 1000000
44+
#define MAX_ACCEL_FILES 1048793
4545
/* Max value of opcache.interned_strings_buffer */
4646
#define MAX_INTERNED_STRINGS_BUFFER_SIZE ((zend_long)MIN( \
4747
MIN( \
@@ -146,6 +146,23 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
146146
zend_accel_error(ACCEL_LOG_WARNING, "opcache.max_accelerated_files is set above the limit (%d).\n", MAX_ACCEL_FILES);
147147
return FAILURE;
148148
}
149+
if (
150+
size != 223
151+
&& size != 463
152+
&& size != 983
153+
&& size != 1979
154+
&& size != 3907
155+
&& size != 7963
156+
&& size != 16229
157+
&& size != 32531
158+
&& size != 65407
159+
&& size != 130987
160+
&& size != 262237
161+
&& size != 524521
162+
&& size != 1048793
163+
) {
164+
zend_accel_error(ACCEL_LOG_WARNING, "opcache.max_accelerated_files should be a value in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793}.\n");
165+
}
149166
*p = size;
150167
return SUCCESS;
151168
}
@@ -307,7 +324,7 @@ ZEND_INI_BEGIN()
307324
STD_PHP_INI_ENTRY("opcache.log_verbosity_level" , "1" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.log_verbosity_level, zend_accel_globals, accel_globals)
308325
STD_PHP_INI_ENTRY("opcache.memory_consumption" , "128" , PHP_INI_SYSTEM, OnUpdateMemoryConsumption, accel_directives.memory_consumption, zend_accel_globals, accel_globals)
309326
STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "8" , PHP_INI_SYSTEM, OnUpdateInternedStringsBuffer, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals)
310-
STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "10000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals)
327+
STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "16229", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals)
311328
STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5" , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage, accel_directives.max_wasted_percentage, zend_accel_globals, accel_globals)
312329
STD_PHP_INI_ENTRY("opcache.force_restart_timeout" , "180" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.force_restart_timeout, zend_accel_globals, accel_globals)
313330
STD_PHP_INI_ENTRY("opcache.revalidate_freq" , "2" , PHP_INI_ALL , OnUpdateLong, accel_directives.revalidate_freq, zend_accel_globals, accel_globals)

‎ext/phar/tests/024-opcache-win32.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ opcache.enable_cli=1
1616
opcache.file_cache={PWD}/024-file_cache
1717
opcache.memory_consumption=64
1818
opcache.interned_strings_buffer=8
19-
opcache.max_accelerated_files=4000
19+
opcache.max_accelerated_files=7963
2020
opcache.jit=tracing
2121
opcache.revalidate_freq=60
2222
opcache.fast_shutdown=1

‎php.ini-development‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,8 @@ ldap.max_links = -1
16841684
;opcache.interned_strings_buffer=8
16851685

16861686
; The maximum number of keys (scripts) in the OPcache hash table.
1687-
; Only numbers between 200 and 1000000 are allowed.
1688-
;opcache.max_accelerated_files=10000
1687+
; Only numbers in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793} are allowed.
1688+
;opcache.max_accelerated_files=16229
16891689

16901690
; The maximum percentage of "wasted" memory until a restart is scheduled.
16911691
;opcache.max_wasted_percentage=5

‎php.ini-production‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,8 +1686,8 @@ ldap.max_links = -1
16861686
;opcache.interned_strings_buffer=8
16871687

16881688
; The maximum number of keys (scripts) in the OPcache hash table.
1689-
; Only numbers between 200 and 1000000 are allowed.
1690-
;opcache.max_accelerated_files=10000
1689+
; Only numbers in {223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793} are allowed.
1690+
;opcache.max_accelerated_files=16229
16911691

16921692
; The maximum percentage of "wasted" memory until a restart is scheduled.
16931693
;opcache.max_wasted_percentage=5

0 commit comments

Comments
 (0)