Zend OPcache – some info and a GUI

Last modified date

Comment: 1

I’ve just started to use Zend OPcache in place of APC in a few places and so far it’s great!

Because documentation seems a little scarce right now, I’ve decided to jot down the methods available (mainly so I don’t forget).

opcache_reset
Should be pretty obvious given the name – resets the opcache

opcache_get_configuration
This will return an array with three indices, one for the directives that have been set, one for version information and one for any blacklisted paths. For example:

[code lang=”php”]
Array
(
[directives] => Array
(
[opcache.enable] => 1
[opcache.enable_cli] => 1
[opcache.use_cwd] => 1
[opcache.validate_timestamps] => 1
[opcache.inherited_hack] => 1
[opcache.dups_fix] =>
[opcache.revalidate_path] =>
[opcache.log_verbosity_level] => 1
[opcache.memory_consumption] => 134217728
[opcache.max_accelerated_files] => 4000
[opcache.max_wasted_percentage] => 0.05
[opcache.consistency_checks] => 0
[opcache.force_restart_timeout] => 180
[opcache.revalidate_freq] => 2
[opcache.preferred_memory_model] =>
[opcache.blacklist_filename] =>
[opcache.max_file_size] => 0
[opcache.error_log] =>
[opcache.protect_memory] =>
[opcache.save_comments] => 1
[opcache.load_comments] => 1
[opcache.fast_shutdown] => 1
[opcache.enable_file_override] =>
[opcache.optimization_level] => 2147483647
)

[version] => Array
(
[version] => 7.0.2-dev
[opcache_product_name] => Zend OPcache
)

[blacklist] => Array
(
)

)
[/code]

opcache_get_status
This will return that holds information about whether the opcache is turned on or not, whether it’s in a restart phase, the memory usage and hit statistics, and any files that have been cached along with hit and memory details. For example:

[code lang=”php”]
Array
(
[opcache_enabled] => 1
[cache_full] =>
[restart_pending] =>
[restart_in_progress] =>
[memory_usage] => Array
(
[used_memory] => 9395880
[free_memory] => 121987104
[wasted_memory] => 2834744
[current_wasted_percentage] => 2.1120488643646
)

[opcache_statistics] => Array
(
[num_cached_scripts] => 353
[num_cached_keys] => 1546
[max_cached_keys] => 7963
[hits] => 27055
[start_time] => 1365412384
[last_restart_time] => 0
[oom_restarts] => 0
[hash_restarts] => 0
[manual_restarts] => 0
[misses] => 509
[blacklist_misses] => 0
[blacklist_miss_ratio] => 0
[opcache_hit_rate] => 98.153388477725
)

[scripts] => Array
(
[/http/includes/libs/ZF-1.12.2/Zend/Loader/Autoloader.php] => Array
(
[full_path] => /http/libs/ZF-1.12.2/Zend/Loader/Autoloader.php
[hits] => 175
[memory_consumption] => 63320
[last_used] => Mon Apr 8 16:21:14 2013
[last_used_timestamp] => 1365434474
[timestamp] => 1343660895
)

[/http/www-includes/libs/ZF-1.12.2/Zend/Db/Adapter/Oracle.php] => Array
(
[full_path] => /http/libs/ZF-1.12.2/Zend/Db/Adapter/Oracle.php
[hits] => 17
[memory_consumption] => 60600
[last_used] => Mon Apr 8 16:21:14 2013
[last_used_timestamp] => 1365434474
[timestamp] => 1325795702
)

[/http/libs/ZF-1.12.2/Zend/View/Helper/Placeholder/Container.php] => Array
(
[full_path] => /http/libs/ZF-1.12.2/Zend/View/Helper/Placeholder/Container.php
[hits] => 175
[memory_consumption] => 2744
[last_used] => Mon Apr 8 16:21:14 2013
[last_used_timestamp] => 1365434474
[timestamp] => 1325795702
)

)

)
[/code]

GUI

APC did have a GUI which was quite handy to see what had been cached, settings and memory usage but Zend OPcache doesn’t (currently as far as I could see) have anything similar.

It is possible to get information from looking at the output of phpinfo() which contains all of the key information.

However, I’ve just pushed the start of a GUI to GitHub. If you want to make changes and improvements then please feel free! It’s only had a very little amount of work done on it so far so is pretty raw.

Share

1 Response

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.