com php-src: Added information about interned strings usage: NEWS ext/opcache/ZendAccelerator.c ext/opcache/zend_accelerator_ module.c
| From: | Dmitry Stogov | Date: | Fri, 21 Feb 2014 08:43:42 +0000 |
| Subject: | com php-src: Added information about interned strings usage: NEWS ext/opcache/ZendAccelerator.c ext/opcache/zend_accelerator_ module.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76164@lists.php.net to get a copy of this message | ||
Commit: 851f36288299ff3dc4f8ff6d0fd9e5f56211d583
Author: Dmitry Stogov <dmitry@zend.com> Fri, 21 Feb 2014 12:43:42 +0400
Parents: f06b3432c80e5c40678a9314d97da220d5cfd678
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=851f36288299ff3dc4f8ff6d0fd9e5f56211d583
Log:
Added information about interned strings usage
Changed paths:
M NEWS
M ext/opcache/ZendAccelerator.c
M ext/opcache/zend_accelerator_module.c
Diff:
diff --git a/NEWS b/NEWS
index d37bb71..f0347a3 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ PHP NEWS
- OPCache
. Added function opcache_is_script_cached(). (Danack)
+ . Added information about interned strings usage. (Terry, Julien, Dmitry)
- Openssl:
. Fixed bug #66501 (Add EC key support to php_openssl_is_private_key).
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index d174f2a..4406400 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -338,6 +338,7 @@ const char *accel_new_interned_string(const char *arKey, int nKeyLength, int fre
if (ZCSG(interned_strings_top) + ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength) >=
ZCSG(interned_strings_end)) {
/* no memory, return the same non-interned string */
+ zend_accel_error(ACCEL_LOG_WARNING, "Interned string buffer overflow");
return arKey;
}
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index b15c080..9d7a5a9 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -444,6 +444,14 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
php_info_print_table_row(2, "Free memory", buf);
snprintf(buf, sizeof(buf), "%ld", ZSMMG(wasted_shared_memory));
php_info_print_table_row(2, "Wasted memory", buf);
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) &&
ZCSG(interned_strings_top)) {
+ snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_top) -
ZCSG(interned_strings_start));
+ php_info_print_table_row(2, "Interned Strings Used memory", buf);
+ snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_end) -
ZCSG(interned_strings_top));
+ php_info_print_table_row(2, "Interned Strings Free memory", buf);
+ }
+#endif
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_direct_entries);
php_info_print_table_row(2, "Cached scripts", buf);
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_entries);
@@ -573,6 +581,20 @@ static ZEND_FUNCTION(opcache_get_status)
add_assoc_double(memory_usage, "current_wasted_percentage", (((double)
ZSMMG(wasted_shared_memory))/ZCG(accel_directives).memory_consumption)*100.0);
add_assoc_zval(return_value, "memory_usage", memory_usage);
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) &&
ZCSG(interned_strings_top)) {
+ zval *interned_strings_usage;
+
+ MAKE_STD_ZVAL(interned_strings_usage);
+ array_init(interned_strings_usage);
+ add_assoc_long(interned_strings_usage, "buffer_size", ZCSG(interned_strings_end) -
ZCSG(interned_strings_start));
+ add_assoc_long(interned_strings_usage, "used_memory", ZCSG(interned_strings_top) -
ZCSG(interned_strings_start));
+ add_assoc_long(interned_strings_usage, "free_memory", ZCSG(interned_strings_end) -
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);
+ }
+#endif
+
/* Accelerator statistics */
MAKE_STD_ZVAL(statistics);
array_init(statistics);