Skip to content

Commit a5bab16

Browse files
jack-wormanJack Worman
authored andcommitted
Improve opcache.max_accelerated_files validation
1 parent 34a2949 commit a5bab16

6 files changed

Lines changed: 27 additions & 10 deletions

File tree

.github/workflows/test-suite.yml

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

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( \
@@ -132,6 +132,23 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
132132
zend_accel_error(ACCEL_LOG_WARNING, "opcache.max_accelerated_files is set above the limit (%d).\n", MAX_ACCEL_FILES);
133133
return FAILURE;
134134
}
135+
if (
136+
size != 223
137+
&& size != 463
138+
&& size != 983
139+
&& size != 1979
140+
&& size != 3907
141+
&& size != 7963
142+
&& size != 16229
143+
&& size != 32531
144+
&& size != 65407
145+
&& size != 130987
146+
&& size != 262237
147+
&& size != 524521
148+
&& size != 1048793
149+
) {
150+
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");
151+
}
135152
*p = size;
136153
return SUCCESS;
137154
}
@@ -293,7 +310,7 @@ ZEND_INI_BEGIN()
293310
STD_PHP_INI_ENTRY("opcache.log_verbosity_level" , "1" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.log_verbosity_level, zend_accel_globals, accel_globals)
294311
STD_PHP_INI_ENTRY("opcache.memory_consumption" , "128" , PHP_INI_SYSTEM, OnUpdateMemoryConsumption, accel_directives.memory_consumption, zend_accel_globals, accel_globals)
295312
STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "8" , PHP_INI_SYSTEM, OnUpdateInternedStringsBuffer, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals)
296-
STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "10000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals)
313+
STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "16229", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals)
297314
STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5" , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage, accel_directives.max_wasted_percentage, zend_accel_globals, accel_globals)
298315
STD_PHP_INI_ENTRY("opcache.force_restart_timeout" , "180" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.force_restart_timeout, zend_accel_globals, accel_globals)
299316
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)