Domas Mituzas wrote:
Performance-wise it is even better, if all main messages which have {{SITENAME}} get replacements with literals. Otherwise you're adding up 5ms of page load time to each page. :)
I'm not very familiar at all with the new LocalisationCache system, but it seems to me that it might be possible (and useful, from a performance viewpoint) to pre-substitute some essentially constant expressions (which only depend on things like configuration variables in LocalSettings) in advance when the cache is populated.
I can think of at least the following magic words that probably could be so substituted:
* {{SITENAME}} * {{CONTENTLANGUAGE}}, {{DIRMARK}} * {{SERVER}}, {{SERVERNAME}}, {{SCRIPTPATH}}
Also, the following parametric parser functions could be pre-substituted if their arguments are constant (possibly after being themselves substituted):
* {{grammar:}}, {{plural:}} * {{ns:}}, {{nse:}}, {{#special:}} * {{localurl:}}, {{fullurl:}}, {{filepath:}} * {{urlencode:}}, {{anchorencode:}} * {{#language:}}
Actually, almost all parametric parser functions could potentially be constant-folded -- for the localization cache, I think it should be possible to do that even for {{int:}}. Furthermore, conditional parser functions like {{plural:}} and {{#if:}} could be folded as long as just their first parameter is constant.
There would, of course, have to be a configurable list of exceptions: for example, if secure.wikimedia.org shares its localization caches with the non-https versions of the wikis, then {{SERVER}}, {{fullurl:}}, etc. would have to be marked as non-foldable on Wikimedia wikis. In fact, it might be better to let the site maintainer specify a list of config variables that should be considered volatile, rather than of specific magic words, and just let the code implementing those parser functions check that list and mark various functions foldable or non-foldable accordingly. That way, server admins hopefully won't have to keep updating the exception list every time new magic words are added.
Alas, while this seems like an interesting project to me, and I'd very much like to try developing it, I'd also expect it to take more time than I'm likely to have available in the near future. Thus, I'm tossing this idea out for discussion and to see if anyone else might be interested in doing something like it.