mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-11715: opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong
This commit is contained in:
commit
e90c96bc8d
3 changed files with 25 additions and 6 deletions
|
@ -2864,7 +2864,7 @@ static zend_result zend_accel_init_shm(void)
|
|||
zend_shared_alloc_lock();
|
||||
|
||||
if (ZCG(accel_directives).interned_strings_buffer) {
|
||||
accel_shared_globals_size = ZCG(accel_directives).interned_strings_buffer * 1024 * 1024;
|
||||
accel_shared_globals_size = sizeof(zend_accel_shared_globals) + ZCG(accel_directives).interned_strings_buffer * 1024 * 1024;
|
||||
} else {
|
||||
/* Make sure there is always at least one interned string hash slot,
|
||||
* so the table can be queried unconditionally. */
|
||||
|
@ -2905,7 +2905,7 @@ static zend_result zend_accel_init_shm(void)
|
|||
ZCSG(interned_strings).top =
|
||||
ZCSG(interned_strings).start;
|
||||
ZCSG(interned_strings).end =
|
||||
(zend_string*)((char*)accel_shared_globals +
|
||||
(zend_string*)((char*)(accel_shared_globals + 1) + /* table data is stored after accel_shared_globals */
|
||||
ZCG(accel_directives).interned_strings_buffer * 1024 * 1024);
|
||||
ZCSG(interned_strings).saved_top = NULL;
|
||||
|
||||
|
|
19
ext/opcache/tests/gh11715.phpt
Normal file
19
ext/opcache/tests/gh11715.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
GH-11715 (opcache.interned_strings_buffer either has no effect or opcache_get_status() / phpinfo() is wrong)
|
||||
--EXTENSIONS--
|
||||
opcache
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.interned_strings_buffer=16
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$info = opcache_get_status()['interned_strings_usage'];
|
||||
var_dump($info['used_memory'] + $info['free_memory']);
|
||||
var_dump($info['buffer_size']);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(16777216)
|
||||
int(16777216)
|
|
@ -41,7 +41,7 @@
|
|||
#define STRING_NOT_NULL(s) (NULL == (s)?"":s)
|
||||
#define MIN_ACCEL_FILES 200
|
||||
#define MAX_ACCEL_FILES 1000000
|
||||
#define MAX_INTERNED_STRINGS_BUFFER_SIZE ((zend_long)((UINT32_MAX-PLATFORM_ALIGNMENT)/(1024*1024)))
|
||||
#define MAX_INTERNED_STRINGS_BUFFER_SIZE ((zend_long)((UINT32_MAX-PLATFORM_ALIGNMENT-sizeof(zend_accel_shared_globals))/(1024*1024)))
|
||||
#define TOKENTOSTR(X) #X
|
||||
|
||||
static zif_handler orig_file_exists = NULL;
|
||||
|
@ -525,7 +525,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
|
|||
snprintf(buf, sizeof(buf), "%zu", ZSMMG(wasted_shared_memory));
|
||||
php_info_print_table_row(2, "Wasted memory", buf);
|
||||
if (ZCSG(interned_strings).start && ZCSG(interned_strings).end) {
|
||||
snprintf(buf, sizeof(buf), "%zu", (size_t)((char*)ZCSG(interned_strings).top - (char*)ZCSG(interned_strings).start));
|
||||
snprintf(buf, sizeof(buf), "%zu", (size_t)((char*)ZCSG(interned_strings).top - (char*)(accel_shared_globals + 1)));
|
||||
php_info_print_table_row(2, "Interned Strings Used memory", buf);
|
||||
snprintf(buf, sizeof(buf), "%zu", (size_t)((char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).top));
|
||||
php_info_print_table_row(2, "Interned Strings Free memory", buf);
|
||||
|
@ -686,8 +686,8 @@ ZEND_FUNCTION(opcache_get_status)
|
|||
zval interned_strings_usage;
|
||||
|
||||
array_init(&interned_strings_usage);
|
||||
add_assoc_long(&interned_strings_usage, "buffer_size", (char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).start);
|
||||
add_assoc_long(&interned_strings_usage, "used_memory", (char*)ZCSG(interned_strings).top - (char*)ZCSG(interned_strings).start);
|
||||
add_assoc_long(&interned_strings_usage, "buffer_size", (char*)ZCSG(interned_strings).end - (char*)(accel_shared_globals + 1));
|
||||
add_assoc_long(&interned_strings_usage, "used_memory", (char*)ZCSG(interned_strings).top - (char*)(accel_shared_globals + 1));
|
||||
add_assoc_long(&interned_strings_usage, "free_memory", (char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).top);
|
||||
add_assoc_long(&interned_strings_usage, "number_of_strings", ZCSG(interned_strings).nNumOfElements);
|
||||
add_assoc_zval(return_value, "interned_strings_usage", &interned_strings_usage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue