R.P
R.P

Reputation: 500

Zend OPcache performance settings vs default settings

As much as I understand those settings:

opcache.validate_timestamps=0
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=3907
opcache.blacklist_filename=/blacklisted_files

should improve performance (according to links: 1, 2 and 3). I´m not actually sure about last 2 and in my case, "internet_strings_buffer" setting value "4" might never be filled (therefore not giving better results), but "validate_timestamps" should remove stat() function overhead and therefore give me better performance, but according to my tests with JMeter, I cannot validate that. Each setting separately is worse than default settings.

I understand that "performance settings" might not improve a lot, but I think it shouldn´t perform worse (difference is about +2 ms for each request).

Question is: Why are default settings better than performance/recommended settings?

Also does OPcache handle smaller memory overwriting/removing/searching better than larger (talking about "opcache.memory_consumption" setting)?

Upvotes: 3

Views: 1021

Answers (1)

TerryE
TerryE

Reputation: 10888

Options 2 and 3 are only indirectly abut performance in that they relate to the capacity of the opcode cache. If your current usage fits within the defaults then you won't see any material difference other a slight increase in system overhead of using Opcache. Of course you will get a benefit if current usage doesn't fit because the cache will have a greater capacity and you'll get less cache misses.

Option 4 relates to defining patterns for PHP script filenames which are volatile and therefore should not be cached. This is particularly important if you have disabled timestamp validation as such changes won't be picked up by Opcache.

Option 1 does remove extra stat() calls which an strace of the PHP process can verify. With modern CPUs, the Linux kernel caches inodes pretty efficiently so this only saves sub mSec if the node is in the VFAT cache. You'd need to construct the timing test pretty well to measure this difference.

Opcache has a very poor reuse strategy: it doesn't bother. The cache slowly fills and when full it is flushed in its entirety and rebuilt from scratch.

Upvotes: 4

Related Questions