zendtech / ZendOptimizerPlus

Other
914 stars 142 forks source link

Hitrate approaching ~60% *sometimes* instead of 100% #189

Closed njam closed 9 years ago

njam commented 10 years ago

Our opcache is for some reason not caching certain files, sometimes after restarting php-fpm. It then approaches a hit rate of around 60%. The server is pretty busy, and usually the rate almost instantly reaches 100%.

screen shot 2014-03-25 at 16 28 55 The rate goes up over a few days to eventually also reach 100%.

When setting the log verbosity to debug (4) I can see that opcache caches many files ("Message Cached script"), but that certain directory trees within the application never show up. It looks like it's ignoring certain directories completely.

Any ideas on what could cause this? Or how I could further debug this?

PHP: 5.4.4-14+deb7u12 Opcache: 7.0.3 Filesystem: Local ext4

njam commented 10 years ago

...and my config:

zend_extension=/usr/lib/php5/extensions/opcache.so

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=1024
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=50000
opcache.fast_shutdown=1
opcache.validate_timestamps=0
opcache.error_log=/var/log/php/opcache.log
opcache.log_verbosity_level=2

There's enough memory: free_memory reports ~1GB.

I also checked reported num_cached_keys. It corresponds as expected to the hit rate. These files are definitely not cached - or rather just very seldomly/slowly over a few days..

screen shot 2014-07-31 at 13 26 53

njam commented 9 years ago

My bad, we misinterpreted opcache_hit_rate. Since the rate is the division of hits and request since opcache was started, it might take a long time to get the rate to 100%. Imagine you have 1 mio misses within the first second. Then you'll need 10 mio hits to get the rate to 91%.

It would be nice to have a rate available that's based on the current hit and miss rate (delta within some time). But anyway it's not a bug.

Thanks @kris-lab for the investigation!