Problem/Motivation
Drupal 8 can be anything up to 2-3 times faster with an opcode cache. I've seen pages take 180ms with opcache enabled, and 480ms without.
Also after doing some memory profiling I forgot to disable opcache (actually I re-enabled it, but in a file that was overridden by another php.ini elsewhere that had it disabled), and was shocked how slow everything was.
Proposed resolution
Add a hook_requirements() that checks for either APC or Opcache, and warns if neither are enabled, this should be both on install and runtime.
We could also get a rough idea of the memory allocation required for standard profile and warn if it's under that too - since Drupal usually requires more than the default and especially APC hates having a full cache.
Remaining tasks
Decide if this is a good idea. The only drawback is that some hosts may not provide an opcode cache, and then users will be stuck with a warning they can't do anything about. But at this point they are probably better off changing hosting if this isn't resolvable.
User interface changes
Yes.
API changes
No.
Comment | File | Size | Author |
---|---|---|---|
#23 | add_a-2502507-23.patch | 1.28 KB | cilefen |
#23 | interdiff-2502507.txt | 622 bytes | cilefen |
#21 | add_a-2502507-21.patch | 1.29 KB | cilefen |
#21 | interdiff-2502507-13-21.txt | 2.22 KB | cilefen |
#13 | add_a-2502507-13.patch | 1.24 KB | cilefen |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman at Acquia commented+1.
There could be a module that alters away the warning for sites that dont are stuck or dont care.
Comment #2
cilefen CreditAttribution: cilefen commentedFor runtime, are we are talking about the system status report? If so, +1.
Comment #3
umarzaffer CreditAttribution: umarzaffer at Srijan | A Material+ Company commentedSubmitting initial patch, however need suggestions for the following -
Thanks
Comment #4
dawehnerWhat about telling users, which don't have it installed, how to enable OP cache, like linking to some specific page.
Btw. http://php.net/manual/de/opcache.installation.php is not entirely 100% helpful
Comment #5
cilefen CreditAttribution: cilefen commentedThe cache that ought to be used depends on the PHP version. I could be wrong, but < 5.5 should use APC and >= 5.5 should use Zend Opcache.
Comment #6
cilefen CreditAttribution: cilefen commented#2296557: [policy] Require PHP 5.5
Comment #7
Wim Leers#6: you beat me to it by 8 minutes :D
Comment #8
kfitz CreditAttribution: kfitz at Acro Commerce commentedI agree with both of these comments. Linking to documentation will be helpful for users, as will informing on status if more then one OP cache is installed; perhaps the former warrants throwing another warning.
As per the Proposed Resolution:
The patch has not quite addressed this aspect of the issue yet, but other than that everything looks good!
Comment #9
Wim LeersGiven #2296557-145: [policy] Require PHP 5.5, where Dries has decided to ship Drupal 8 with requiring PHP 5.5, this issue no longer needs to be fixed, because 5.5 ships with the OpCache extension enabled by default.
But… it's still possible to disable that extension. So… perhaps we should still do this?
Comment #10
dawehnerIts not only that, you can also just configure it and I think on ubuntu it hasn't been enabled by default.
Comment #11
catchYes I think we need to check specifically for
opcache.enable
- no good having the extension enabled and actual opcode caching disabled.Also in a follow-up, we could check
opcache.memory_consumption
and opcache_get_status() and warn people if the cache is full.Comment #12
moshe weitzman CreditAttribution: moshe weitzman at Acquia commentedWe would save significant hassles with this I think.
Comment #13
cilefen CreditAttribution: cilefen commentedThis is a reworking of #3, now that APC is out of the picture.
Comment #15
catchCould probably check for #2551309: Increase opcache.max_accelerated_files here too.
Comment #17
serg2 CreditAttribution: serg2 commentedIn regard to the max-accelerated files side of it, 16228 as the minimum value to look for would makes sense.
Comment #18
moshe weitzman CreditAttribution: moshe weitzman at Acquia commentedLets just get this bit in. I'd rather bikeshed other limits in a new issue.
Comment #19
alexpottIf I disable opcache using
in php.ini this still reports opcache as being on.
Comment #20
cilefen CreditAttribution: cilefen commentedHow DARE you actually check the patches? Ha ha. We need a new runtime test.
Comment #21
cilefen CreditAttribution: cilefen commentedThis one actually works!
Comment #22
moshe weitzman CreditAttribution: moshe weitzman at Acquia commentedThe == TRUE part is superflous. Can be fixed on commit if cilefen doesn't get to it.
Comment #23
cilefen CreditAttribution: cilefen commentedComment #24
cilefen CreditAttribution: cilefen commented@moshe weitzman Thank you for reviewing.
Comment #25
alexpottCommitted f617434 and pushed to 8.0.x. Thanks!
Comment #28
omega8cc CreditAttribution: omega8cc commentedThe current check is too demanding and as a consequence, doesn't allow to use more secure settings, like
opcache.restrict_api
protection, because it will in turn auto-disableopcache_get_status()
. We should instead use the check Symfony already has in place:This allows to configure any restrictions the server admin wants to avoid data leaks (like paths to scripts between sites on the same system) which are available if you allow
opcache_get_status()
to satisfy Drupal current requirements.Comment #29
omega8cc CreditAttribution: omega8cc commentedIn fact, we could even re-use the check we already have for the only opcache function used in core:
if (function_exists('opcache_invalidate')) {}
Comment #30
cilefen CreditAttribution: cilefen commented@omega8cc Good idea, but open a followup for this and refer to it here please. The reason is that similar syntax is used in #2421451: Drupal needs comments in opcache and we may as well fix them both.
Comment #31
omega8cc CreditAttribution: omega8cc commented@cilefen -- OK, I have created issue #2639878: Use less demanding check to see if OPcache is active
Comment #32
cilefen CreditAttribution: cilefen commented