drupalci_testbot icon indicating copy to clipboard operation
drupalci_testbot copied to clipboard

Enable OpCache on PHP 5.5, and optimize its settings for testing Drupal 8 core

Open wimleers opened this issue 11 years ago • 8 comments

http://php.net/manual/en/opcache.configuration.php lists the defaults for PHP 5.5's OpCache.

Sadly, it also lists opcache.enable_cli as being disabled by default. Let's enable it :)

Also, opcache.max_accelerated_files is 2000 by default. A quick git ls-files | wc -l returns the beautiful number 10807 for me. That's not all PHP files of course. But let's bump that to 12000, then we have some room for growth, so we won't need to adjust this setting any time soon.

Which brings us to opcache.memory_consumption, which defaults to 64. That seems too low, especially if we increase the accelerated files limit by so much. What about 256?

The default revalidation settings are probably fine because everything lives in memory, so file system hits will be supersonically fast.

So, I propose:

opcache.enable_cli = 1
opcache.max_accelerated_files = 2000
opcache.memoryo_consumption = 256

wimleers avatar Sep 19 '14 08:09 wimleers

My understanding is that opcache is of minimal use with CLI because the opcache has nowhere to be persisted between CLI requests. So it gets built up and discarded on every request. Confirmed by http://stackoverflow.com/questions/25044817/zend-opcache-opcache-enable-cli-1-or-0-what-does-it-do

weitzman avatar Sep 19 '14 14:09 weitzman

Nice find, Moshe.

Looks like these changes are still relevant. there was a typo on memory_o__consumption.

opcache.max_accelerated_files = 2000 opcache.memory_consumption = 256

greggles avatar Oct 30 '14 19:10 greggles

I saw some minimal improvements with my D7 tests using the above two adjustments. Note that I think Wim meant

opcache.max_accelerated_files = 12000

instead of 2000.

Btw, git ls-files | grep \.php | wc -l gives me something just north of 7800, so rounding up to 8000 would probably be fine.

mikeker avatar Nov 17 '14 19:11 mikeker

For what it's worth, the documentation for opcache.max_accelerated_files integer says:

The maximum number of keys (and therefore scripts) in the OPcache hash table. The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987 } that is bigger than the configured value. Only numbers between 200 and 100000 are allowed.

So for a value of 12000, the opcache will actually use 16229.

alanorth avatar May 09 '15 09:05 alanorth

Hey guys I really have a problem installing and configuring opcache in my drupal setup. I could really use a tutorial/step-by-step guide to setting up opcache. Please help me out here !!!

Migtymike avatar Nov 17 '15 20:11 Migtymike

There is a thread at the official Drupal.org site: https://groups.drupal.org/node/305178 Please see/ask there.

ricardoamaro avatar Nov 18 '15 21:11 ricardoamaro

If current clean install has 8257 inc+php files in D8, then I'm pretty sure this can double easily with contrib. Future proof would be atleast 16229

hkirsman avatar Nov 22 '15 13:11 hkirsman

Note also that this number of files is for a single drupal install. If you have a couple of drupal installations, and maybe some other php stuff, the number of php files will increase.

I presume though that this is the number of files that can be cached at once, not the number of files that can exist, and there are many rarely used files that won't matter much if their cache hit rate is low.

mc0e avatar Feb 16 '16 03:02 mc0e