The Monitoring Dashboard provides an overview of the caches usage and hit-rate evolution over time for PHP applications:
The hit rate is the number of cache hits divided by the total number of memory requests over a given time interval.
The cache usage is the percentage of a specific cache memory currently allocated.
OPcache is a PHP extension that improves application performance by storing precompiled script, opcodes, in shared memory. It removes the need to load, parse and compile PHP files on every request.
The opcache.memory_consumption ini setting defines the size of the shared memory storage used by this cache.
Interned strings are a memory optimization added in PHP 5.4. PHP stores
immutable strings (a char *) into a special buffer to be able to reuse its
pointer for all occurrences of the same string.
Blackfire recommends that the interned strings buffer does not represent more than 85% of the allocated memory.
This setting can be adjusted using the opcache.interned_strings_buffer.
The opcache.max_accelerated_files
ini setting configures the maximum number of files that can be cached. Complex
applications involve a lot of different PHP files, so it's recommended to
increase the default value of opcache.max_accelerated_files in production.
The realpath() function
returns the absolute path for any given relative file path. This conversion takes
a non-negligible time because it performs some filesystem calls. That's why PHP
caches the results of realpath() calls and their associated
stat() calls. The
realpath_cache_size
ini setting defines the size of this cache.
The PCRE PHP extension maintains a per-thread cache of compiled regular expressions (one global cache in NTS builds, one per thread in ZTS builds such as FrankenPHP), hardcoded to 4096 entries. Unlike the other caches listed above, this limit is not configurable via an INI setting. When the cache is full, up to 512 of the oldest entries (by insertion order) that are not currently in use are evicted in bulk. High cache usage indicates frequent evictions and regex recompilation; the only mitigation is to reduce the number of unique regex patterns in the application code.