Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./opcache-gui-3.3.0/index.php only shows itself as being cached, but no other files #76

Open
reteP-riS opened this issue Nov 19, 2021 · 5 comments

Comments

@reteP-riS
Copy link

I downloaded version 3.3.0, copied all the files into a ./opcache-gui-3.3.0 subdirectory of my web application and then created a link to the ./opcache-gui-3.3.0/index.php file in the top folder of my web application.

When pointing my browser to the ./opcache-gui-3.3.0/index.php file via that link everything seemed to work as expected, but then I noticed that it only shows a single file as being cached which is the ./opcache-gui-3.3.0/index.php file itself. None of the other application files are shown as being cached although I can see all the xyz.php.bin files in the opcache folder together with ./opcache-gui-3.3.0/index.php.bin.

What am I missing here?

@amnuts
Copy link
Owner

amnuts commented Nov 25, 2021

Hi @reteP-riS; sorry fore the slow reply - I just didn't see that you had posted up here.

Not sure, tbh. All you should need is the index,php file to be running. So maybe getting some more info from you would help.

For example, are you running with opcache.file_cache_only on? If so, that might be affecting it because the opcache functionality doesn't (last I looked) return any of the data for file-based cached files. (But then that wouldn't really explain why the index.php is showing up and not the others).

Are they all on the same domain/host? And are they all served in the same way (all apache, or nginx, or FastCGI, etc.)?

Maybe a screenshot or your a copy/paste of your directives might throw some light on the matter? If it can be replicated then we might be able to figure out the answer and help resolve it.

@reteP-riS
Copy link
Author

Hi @amnuts, thanks for your reply. No need to hurry.

All you should need is the index,php file to be running.

The situation is the same regardless of whether I only use the index.php file or the complete package.

are you running with opcache.file_cache_only on?

No, opcache-gui displays file_cache_only="false" and php.ini has the following configuration.

zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=32
opcache.interned_strings_buffer=16
opcache.max_file_size=0
opcache.max_accelerated_files=2000
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.revalidate_path=0
opcache.file_cache=/REDACTED/.opcache
opcache.file_cache_only=0
opcache.error_log=/REDACTED/.opcache/error.log
opcache.log_verbosity_level=1

Are they all on the same domain/host?

Yes, all on the same host, but in different folders and every folder is assigned to a different subdomain. The issue is the same with PHP 7.3, 7.4 and 8.0 with phpinfo() reporting Server API = CGI/FastCGI for all three versions.

Whenever I call the opcache-gui index.php file it updates the start time to the current time as if it just started the opcache for the first time. It never shows a last reset time, even if I press the reset button. And as I said in my first post it only shows itself as cached and nothing more although there are hundreds of *.php.bin files in the opcache folder. The opcache-gui must feel very lonely... ;-)

Attached is a pdf file with two screenshots. Thanks a lot for trying to help!

opcache-gui.pdf

@amnuts
Copy link
Owner

amnuts commented Nov 28, 2021

So after looking around a bit, I think this might be expected behaviour, @reteP-riS

If you're using CGI/FastCGI, then there might not be any persistence to the opcache, which is why the start time might always be as if you've only just started it, with no reset time. This Stackoverflow comment explains it: https://stackoverflow.com/a/53203797

As for the /bin files being there, it looks like opcache just doesn't remove them right away depending on how the cache is cleared...

If you were to invalidate an individual file (which in the gui uses opcache_invalidate), then this would lead to the file being unlinked https://github.com/php/php-src/blob/90b7bde61507cee1c6b37f153909d72f5b203b8c/ext/opcache/zend_file_cache.c#L1927. I've checked this with a similar setup to the settings you posted and I do indeed see the individual files being removed from the filesystem.

But when you do a reset cache (which uses opcache_reset), from what I can tell it puts the cache into a 'pending restart' state (https://github.com/php/php-src/blob/0e1c7243f65167fcc6fb4d45c34c8440a7d0a2d0/ext/opcache/ZendAccelerator.c#L3386), but I see no removal of the files. There are some attributes in each of the cache files, so maybe it just updates them to be invalid? But it seems to persist them in the file system.

Once the cache has been reset, the raw opcache_get_status just doesn't return any of the .bin file information for cached files that are there but have been reset. And without the file information being returned from the extension itself, there's nothing the gui can do to display the info.

Hope that helps clarify some things? I'm not very familiar at all with the extension code, so might have missed something.

@MichaIng
Copy link

PHP-FPM would be required to have a persistent OPcache instance across all requests and websites served via the same FPM pool. On regular CGI calls, a new OPcache is created on every request.

But strange is that it doesn't load the file cache. It is meant to be a persistent storage so that when (re)starting a new OPcache instance it should (re)load all files from the file cache right into the shared memory: https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.file-cache

@reteP-riS
Copy link
Author

Amongst other applications I am running a WordPress blog on this server and I am using a plugin called WP OPcache with the same php.ini configuration and CGI/FastCGI. See https://wordpress.org/plugins/flush-opcache/

Surprisingly this plugin shows the SHM details and the cached files correctly. Although I have to admit it shows less cached files than xyz.php.bin files exist in the opcache folder.

I wonder how this WP OPcache plugin successfully attaches to SHM and shows the cached files while opcache-gui can't?

WP-OPcache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants