From 84c39bfc56dcc1402347eb0fd1fa8ab35c372567 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 4 May 2006 06:03:22 +0000 Subject: [PATCH] Added an overview of the CBT project including its status. Moved the template file to the disabled directory. --- includes/cbt/README | 49 +++++++++++++++++++++++++++++++ skins/{ => disabled}/MonoBook.tpl | 0 skins/disabled/MonoBookCBT.php | 4 ++- 3 files changed, 52 insertions(+), 1 deletion(-) rename skins/{ => disabled}/MonoBook.tpl (100%) diff --git a/includes/cbt/README b/includes/cbt/README index ca2ef2c985..1f565e0d1e 100644 --- a/includes/cbt/README +++ b/includes/cbt/README @@ -1,3 +1,49 @@ +Overview +-------- + +CBT (callback-based templates) is an experimental system for improving skin +rendering time in MediaWiki and similar applications. The fundamental concept is +a template language which contains tags which pull text from PHP callbacks. +These PHP callbacks do not simply return text, they also return a description of +the dependencies -- the global data upon which the returned text depends. This +allows a compiler to produce a template optimised for a certain context. For +example, a user-dependent template can be produced, with the username replaced +by static text, as well as all user preference dependent text. + +This was an experimental project to prove the concept -- to explore possible +efficiency gains and techniques. TemplateProcessor was the first element of this +experiment. It is a class written in PHP which parses a template, and produces +either an optimised template with dependencies removed, or the output text +itself. I found that even with a heavily optimised template, this processor was +not fast enough to match the speed of the original MonoBook. + +To improve the efficiency, I wrote TemplateCompiler, which takes a template, +preferably pre-optimised by TemplateProcessor, and generates PHP code from it. +The generated code is a single expression, concatenating static text and +callback results. This approach turned out to be very efficient, making +significant time savings compared to the original MonoBook. + +Despite this success, the code has been shelved for the time being. There were +a number of unresolved implementation problems, and I felt that there were more +pressing priorities for MediaWiki development than solving them and bringing +this module to completion. I also believe that more research is needed into +other possible template architectures. There is nothing fundamentally wrong with +the CBT concept, and I would encourage others to continue its development. + +The problems I saw were: + +* Extensibility. Can non-Wikimedia installations easily extend and modify CBT + skins? Patching seems to be necessary, is this acceptable? MediaWiki + extensions are another problem. Unless the interfaces allow them to return + dependencies, any hooks will have to be marked dynamic and thus inefficient. + +* Cache invalidation. This is a simple implementation issue, although it would + require extensive modification to the MediaWiki core. + +* Syntax. The syntax is minimalistic and easy to parse, but can be quite ugly. + Will generations of MediaWiki users curse my name? + + Template syntax --------------- @@ -53,3 +99,6 @@ should call cbt_value() to get a return value: where $deps is an array of string tokens, each one naming a dependency. As a shortcut, if there is only one dependency, $deps may be a string. + +--------------------- +Tim Starling 2006 diff --git a/skins/MonoBook.tpl b/skins/disabled/MonoBook.tpl similarity index 100% rename from skins/MonoBook.tpl rename to skins/disabled/MonoBook.tpl diff --git a/skins/disabled/MonoBookCBT.php b/skins/disabled/MonoBookCBT.php index c59989ac9f..0474ad7cf0 100644 --- a/skins/disabled/MonoBookCBT.php +++ b/skins/disabled/MonoBookCBT.php @@ -10,7 +10,9 @@ require_once( 'includes/SkinTemplate.php' ); /** * MonoBook clone using the new dependency-tracking template processor. - * EXPERIMENTAL - use only for testing and profiling at this stage + * EXPERIMENTAL - use only for testing and profiling at this stage. + * + * See includes/cbt/README for an explanation. * * The main thing that's missing is cache invalidation, on change of: * * messages -- 2.20.1