This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.
PHP 7.4+ provides a php script preloading function with the opcache.preload directive.
It requires a file, preload.php is commonly used, to provide a list of the php files to preload.
From https://www.php.net/manual/en/opcache.preloading.php ...
"PHP can be configured to preload scripts into the opcache when the engine starts [...] and load code into persistent memory"
... thus XF php code will remain in memory, instead of having to be processed and loaded each time it's called. Much faster and efficient.
I'd like to see XF provide a preload.php within installation files, listing all the appropriate files in the src/ tree that would benefit with preloading. Admin's wanting to utilise this functionality, can reference the preload.php in their PHP configuration if they desire.
Support for preloading would be nice, but I don't see this happening anytime (soon) as it would be pretty complicated if this should work without limiting what can be done via ACP.
Right now if you want to use preloading, you can't
Install Add-ons via ZIP
Upgrade Add-ons from ACP
Uninstall Add-ons from ACP
Enable Add-ons from ACP
Disable Add-ons from ACP
Disable extensions (class extensions and event listeners) via config.php
Modify class extensions (enable, disable, add, remove, change execution order, etc.) via ACP
Some of those (like enabled/disabling Add-ons) would partly work (but require a PHP reload afterwards) while others (like upgrading an Add-on) would not work at all.
If you accept those limitations, do not run multiple PHP-FPM pools (there can only be one preload per PHP-FPM master process, not per pool) and do not care for templates/phrases being preloaded adding preload support would be fairly easy.
I suggest an admin wanting to get the benefit from preloading would be happy. I already use cli cmd.php for XF upgrades (and add-on actions), so a php restart afterwards would not be a concern.
You didn't state that you only want to preload core files:
I'd like to see XF provide a preload.php within installation files, listing all the appropriate files in the src/ tree that would benefit with preloading.
Often used extensions classes would benefit from preloading, if Add-on files were excluded things would definitly get easier and the a/m limitations would not apply.
I'd like to see XF provide a preload.php within installation files, listing all the appropriate files in the src/ tree that would benefit with preloading.
ACP (and cli cmd.php) upgrade could check for the opcache.preload being active, and if so remind admins to restart php for the upgrade to finalise. I think the majority(all?) server control panels have php restart functions, if the admin doesn't have root/shell access.
The performance benefit from preloading certainly outweighs having to restart php every 2 months or so (approx. XF release cycle)
I don't use control panels, so I can't really comment on that.
Do they also support running multiple PHP-FPM master processes (of the same version) out of the box, eg. one master process per pool?
If not it would be pretty problematic to use preload if there are multiple XF pools (might even cause problems with other pools if vendor classes are preloaded).
Anyway, I am not at all against this suggestion, I just think it is complicated