Skip to content

Commit a282d58

Browse files
westonrutergemini-code-assist[bot]szepeviktor
committed
Add cache full status and interned strings usage to Opcode Cache debug information.
Expanded the Opcode Cache debug data to include: - 'opcode_cache_full': Indicates if the cache has reached its capacity. - 'opcode_cache_interned_strings_usage': Displays the percentage of the interned strings buffer used, the total buffer size, and the amount of free memory. These additions provide more comprehensive diagnostic information for troubleshooting performance issues related to PHP's OPcache. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: szepeviktor <[email protected]>
1 parent 6ef53de commit a282d58

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/wp-admin/includes/class-wp-debug-data.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,23 @@ private static function get_wp_server(): array {
504504
),
505505
);
506506

507+
$fields['opcode_cache_interned_strings_usage'] = array(
508+
'label' => __( 'Opcode cache interned strings usage' ),
509+
'value' => sprintf(
510+
/* translators: 1: Percentage used, 2: Total memory, 3: Free memory */
511+
__( '%1$s%% of %2$s (%3$s free)' ),
512+
number_format_i18n( ( $opcache_status['interned_strings_usage']['used_memory'] / $opcache_status['interned_strings_usage']['buffer_size'] ) * 100, 2 ),
513+
size_format( $opcache_status['interned_strings_usage']['buffer_size'] ),
514+
size_format( $opcache_status['interned_strings_usage']['free_memory'] )
515+
),
516+
'debug' => sprintf(
517+
'%s%% of %s (%s free)',
518+
round( ( $opcache_status['interned_strings_usage']['used_memory'] / $opcache_status['interned_strings_usage']['buffer_size'] ) * 100, 2 ),
519+
$opcache_status['interned_strings_usage']['buffer_size'],
520+
$opcache_status['interned_strings_usage']['free_memory']
521+
),
522+
);
523+
507524
$fields['opcode_cache_hit_rate'] = array(
508525
'label' => __( 'Opcode cache hit rate' ),
509526
'value' => sprintf(
@@ -513,6 +530,12 @@ private static function get_wp_server(): array {
513530
),
514531
'debug' => $opcache_status['opcache_statistics']['opcache_hit_rate'],
515532
);
533+
534+
$fields['opcode_cache_full'] = array(
535+
'label' => __( 'Is the Opcode cache full?' ),
536+
'value' => $opcache_status['cache_full'] ? __( 'Yes' ) : __( 'No' ),
537+
'debug' => $opcache_status['cache_full'],
538+
);
516539
}
517540
}
518541
} else {

0 commit comments

Comments
 (0)