As known, PHP7.4 and newer has OPcache preloading as a new feature to enhance performance: https://www.php.net/manual/en/opcache.preloading.php
It does not only preload the pre-compiled and optimised PHP scripts opcode into memory like OPcache does when a script is called the first time, but it also makes all contained classes, functions, interfaces and traits globally available at all time to all requests, hence they do not need to be loaded on execution:
Any functions, classes, interfaces, or traits (but not constants) in those files will then become globally available for all requests without needing to be explicitly included.
Hence it is superior for performance also in the long term, not only until all script got naturally loaded into OPcache.
But of course there may be scripts which are never loaded, based on enabled/disabled apps, configuration, those which are used by CLI only, documentation stuff etc. Others might be loaded extremely rarely, or they must not be loaded on all requests for other reasons. Loading everything into memory may after have a negative impact on performance, if the additional memory usage leads to swapping, when other caches or the amount of webserver or PHP workers need to be decreased, etc, so it makes sense to preload only those parts which are definitely known to be used regularly on common usage and safe to load at all time.
And of course in theory there may be conflicts between classes, functions, interfaces etc, when defined at multiple places, or when other PHP applications run within the same PHP pool.
So my question is if anyone did already experiment with preloading Nextcloud scripts, or if there is already a generally safe and beneficial list of scripts which can be preloaded? Safe should be the root
index.php, but without a path context, I guess that wouldn’t really preload much?
Maybe we can even work on an official documentation page or at least HowTo here at the forum.