Hello Bjorn, hello Tata,
ahh, an interesting topic. Okay, so what does the plugin loader do, when a CMSimple (I'll ignore additional steps required by _XH) page is requested by an UA? I'm not talking about the admin part, only the front-end:
/plugins/index.php is included
/plugins/*/index.php are included
So if there are 10 (!) plugins installed, 11 files must be read and parsed by PHP (I'm ignoring the PHP cache, which might not help to much on a hosted solution, but I'm not sure about that). I guess for typical plugins the total size will be several hundret KB total.
bjorn wrote:The CMSimple plugin system is extremly wasteful
IMO it is wasteful, but not extremely. Consider content.htm. I've read several times that content.htm > 2 MB should be avoided for performance reasons. This content.htm is also read everytime a CMSimple page is requested. And it's parsed not by the optimized Zend engine, but by simple PHP regexps!
But these are theoretical speculations. So I've made a test with CMSimple_XH (which has even more to do than the plugin loader for CMSimple or CMSimple LE; I've currently have only 2 plugins installed in CMSimple 3.3). I have 7 front-end plugins installed in my plugin dir. I've extended the template with
- Code: Select all
<?php echo microtime(TRUE)-sv('REQUEST_TIME'); ?>
I've requested several different pages with results between 0.3 and 1 seconds. Then I've switched to a non-existent plugin directory, and tried again. I had results between 0.04 and 0.9 seconds. I guess the plugin inclusion makes for an avarage overhead of about 20-30% for a content.htm of 7KB!
Then I tried again with a content.htm of 2.3 MB (343 pages). Without the plugins I've had typical response times from 0.7-1.2 sec. With the plugins it was 0.7-1.5 secs.
My conclusion: the overhead of many plugins is noticeable, as is the overhead of a very large content.htm. At least on my local machine. It is an Intel Atom 1.6. I'm quite sure that a typical webserver will only need a small fraction of the times I've measured (say 5-10%, so we're talking about <100ms). IMHO this could be ignored in comparison to delayed responses from the server and network transmission times.
Another more practical problem is, that all plugins are written to be treated by the plugin loader that way. So if JIT-plugin-loader solution would be developed, it will only help, if the plugins where updated to make use of it. But the current solution of the plugin loader is a very simple and clever one. It reads all necessary PHP files, so that all functions used by templates or content are available immediatly, without requiring special hooks and registrations, so that the loader knows, when to include the files (which would not work for templates, at least the existing ones, which need e.g. newsrotator).
So is there a way to avoid too much overhead by newer plugins growing bigger and bigger without avoiding compatibility problems with older plugins or older plugin loaders? Yes, IMO it is. The only functions that must be defined always, are those that may be used from templates or content. And those functions can be simple stubs, which include the main code only when called, e.g.
- Code: Select all
function genizforum($name) {
global $pth
include_once($pth['folder']['plugins].'genizforum/genizforum.php);
return real_genizforum($name);
}
It is possible to write conforming plugins using such stubs right now. The author of the plugin is responsible for this. This way the only overhead of including the plugin when it is not needed, will be the inclusion of the index.php which has a size of say 1KB. The rest of the plugin's code will be loaded on demand (=JIT).
The situation is somewhat different for the plugin's administration, but that's a) not too important, because it wont be requested as often and b) it could be solved in a similar way.
Christoph