PHP class size vs opcache?

708 views Asked by At

I have a potentially very large (several megabytes perhaps) PHP class, generated of course. Is there any setting or limitation that would cause opcache slowdown in this case?

2

There are 2 answers

1
lisachenko On BEST ANSWER

You should check opcache.max_file_size option. This option can set a maximum file size to cache. Thus, big files can be skipped by opcode cacher. However, it defaults to 0, meaning all files will be cached.

Next option to check is opcache.max_accelerated_files. For big projects with Twig and annotations default value 2000 is not enought. Consider to increase it.

And the last one is opcache.memory_consumption. I noticed, that after reaching this limit, opcache won't add new items into the cache. So, increase it to 256M or 512M.

2
user3278897 On

Few things make OPCache slow, like opcache.consistency_checks if is it enabled, OPcache will verify the cache checksum every N requests, where N is the value of this configuration directive. For your large file size i am sure it is not good idea to enable this.

Also, if you doubt that it is effecting OPCache, why can't you try tools like OpCacheGUI to check it.