Checking OPcache, RealPath Cache, PCRE Cache and OPcache Interned Strings Buffer with Blackfire

By Christophe Dujarric, on May 04, 2018

Correctly configuring PHP caches is critical for optimal performance: you should not get to a full cache. Enterprise users were already able to benefit from Blackfire’s ability to track the usage of OPcache, RealPath Cache, PCRE Cache and OPcache Interned Strings Buffer.

This feature is now available for any paid subscription: Profiler, Premium and Enterprise!

Anytime you profile your code, when viewing the profile data, simply click on the profile name to view the cache information:

Some tips

RealPath Cache

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 realpath cache is only used for file paths that exist and is used for most of PHP filesystem calls. Complex applications involve a lot of file operations, so this cache size must be increased accordingly.

Interned Strings

Interned strings are a nice memory optimization that was 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. This setting can be adjusted using the opcache.interned_strings_buffer.

Get the most out of it with the Quality add-on

The Quality add-on, which we recently released, is all about recommending appropriate php.ini configuration. It will directly warn you whenever your configuration for those caches is incorrect, saving you even more time to optimize performance.

Happy profiling,

Christophe Dujarric

Christophe is the Chief Product Officer at Blackfire. He's an engineer, but probably one of the least "tech" people in the company. He's wearing many hats, from product management to marketing and sales. He loves the beauty of simple solutions that solve actual problems.