?
avatar PhilETaylor
PhilETaylor
2 Apr 2021

Steps to reproduce the issue

On most modern web hosts (I hope) opcache caching is becoming the norm.

In the early days, most people implemented opcache_reset as the "way" to invalidate a sites PHP files from the opcache. There are still a lot of blogs promoting this from the early days of opcache.

However, the documentation states:

opcache_reset - This function resets the entire opcode cache.

This means the ENTIRE SERVER opcache, not just your Joomla site, but all the caches of all the PHP files the running PHP process has a cache for. This, on a shared host, could be hundreds of thousands of PHP files serving hundreds of sites.

Quotes from WordPress 3 years ago:

Under certain PHP configurations, calling opcache_reset will reset the opcache for all users on a given server, or, at the very least, all websites that a given user owns. For example, if a server using PHP-FPM uses a common PHP-FPM master process, despite having separate pools of workers for each worker, calling opcache_reset will reset the opcache for all users on the server using the common PHP-FPM master process. I believe this same behavior occurs when using mod_php (running PHP as a Dynamic Shared Object in Apache) even when using mod_ruid2 or other security modules in Apache

Clearing the opcache for all websites on a server or all websites owned by a single user would likely have a pretty significant impact on performance in terms of traffic that could be served and on website resource usage

There is not a single use of opcache_reset in WordPress 5.7.

Expected result

Joomla is a good neighbour to other sites on a server and doesn't EVER use opcache_reset to avoid invalidating caches that dont belong to this Joomla site.

Actual result

opcache_reset is used at the end of installing plugins and at the end of upgrading Joomla in Joomla 3 and 4

(as well as one use in the phar-stream-wrapper that we have to ignore)

avatar PhilETaylor PhilETaylor - open - 2 Apr 2021
avatar joomla-cms-bot joomla-cms-bot - change - 2 Apr 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Apr 2021
avatar PhilETaylor PhilETaylor - change - 2 Apr 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 2 Apr 2021
avatar PhilETaylor PhilETaylor - change - 2 Apr 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 2 Apr 2021
avatar PhilETaylor PhilETaylor - change - 2 Apr 2021
Title
Dont use opcache_reset
[3/4] Dont use opcache_reset
avatar PhilETaylor PhilETaylor - edited - 2 Apr 2021
avatar simbus82
simbus82 - comment - 2 Apr 2021

I've always suspected it, but I didn't know how to go into it!
Fortunately in my server happen only with hosts that share same PHP version, Unfortunately most of websites are under php 7.4 with opcache :-(

avatar richard67
richard67 - comment - 3 Apr 2021

@PhilETaylor Would it make sense to extend your existing PR’s for the file based invalidation by the removal of these opcache_reset calls?

avatar PhilETaylor
PhilETaylor - comment - 3 Apr 2021

Small, very specific, short, direct to the point PRs have more chance of being tested and merged in my experience.

Unfortunately my time is short as easter is 2 weeks of school holidays, I'll see how much I can actually personally get done.

It does need addressing though.

avatar PhilETaylor
PhilETaylor - comment - 4 Apr 2021

Moved to PR #32915 for Joomla 4

avatar PhilETaylor PhilETaylor - change - 4 Apr 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-04-04 11:15:57
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 4 Apr 2021

Add a Comment

Login with GitHub to post a comment