We seem to be in the process of refactoring areas of the current implementation into normalised modules to enhance the maintainability of the source base. Whilst this has many benefits, this also means for a "compile and go" language like PHP that the source becomes more fragmented and therefore the number of modules that need to be loaded in order to generate a page is continuing to rise. This isn't a significant problem for high volume boards which have implemented a PHP code accelerator cache (e.g. Xcache). However for lower volume boards, they won't have such caching and the php source files will be slowly cycled out of the file system cache; each extra module to be loaded can require an extra two seeks when this happens, leading to an extra time delay of perhaps 0.1-0.3 secs on page rendering response. These loads can all build up to quite material response delays.
At the moment the template preprocessing removes the runtime overhead of mapping the various <!-- block --> tags onto the conditional code to do this work. This is independent of language so a lot of error checking and binding has to be retained at runtime, but this could largely be eliminated by the following changes:
- Instead of generating a tpl module per style/HTML_template we generate a compiled_template class module per style/language/display_page. that is tpl_prosilver_forumlist_body.html.php is replaced by tpl_prosilver_en_forumlist.html.php:
- The common and page specific language files are preprocessed at template generation, and the results rolled up into a get_lang method -- which is probably just an unserialize call to an embedded (and rather large) literal. This template needs to be bound before language references are needed and this call to a get_lang() method can then replace the includes of the language files. (OK, there are a some rare early error conditions which require language strings before this call point but these can be handled by a lazy include of common.php.)
- This denormalisation may see to be a combinatorial explosion, but in reality few forums implement more than one or two languages and only one language / style combination is ever needed per request.
- This also means that we can hoist a lot more error checking into the compile phase (such as comparing language X to EN and flagging missing keys) and log this for review in the ACP.
- Most language string can be bound at preprocessing time so whilst a "{L_PRINT_TOPIC}" reference currently generates "<?php echo ((isset($this->_rootref['L_PRINT_TOPIC'])) ? $this->_rootref['L_PRINT_TOPIC'] : ((isset($user->lang['PRINT_TOPIC'])) ? $user->lang['PRINT_TOPIC'] : '{ PRINT_TOPIC }')); ?>);" this would now be replaced by the literal value of the PRINT_TOPIC string, etc.
- Because the tpl is a proper class we can split out default setting for variables into a separate method so that the main display doesn't need to embed the convolved isset() conditionals. It would just include at it's head a $this->set_defaults() call.
- Include files could also be rolled up at preprocessing time. Hence where a page currently loads 5-6 tpl and language files, these would be replaced by a single cache module which will be smaller and leaner than their combined size.
- This approach would only need small changes at a source level since the guts would be included in the template classes.