When profiling symfony 1.x applications hydrating Doctrine objects occurs to be one of the most time consuming operations. Recently I experienced something different. Loading ORM classes was one of the most expensive tasks. Usually such operations don't even show up during profiling.
Fortunately Doctrine comes with a special task which merges all its classes into one file. This way number of require statements is significantly reduced.
sfTaskExtraPlugin comes with doctrine:compile task for symfony (which is really a wrapper for doctrine script).
Note: mentioned application was deployed to the server suffering from several issues (i.e. invalid APC configuration). Those issues made class loading problem more visible. Nevertheless compilation played a role in improving overall performance.
sfTaskExtraPlugin installation
./symfony plugin:install sfTaskExtraPlugin
Doctrine Compilation
Following command will compile Doctrine classes into _lib/doctrine.compiled.php _file with only mySQL support:
./symfony doctrine:compile --driver=mysql lib/doctrine.compiled.php
Just like the output message will suggest we need to alter ProjectConfiguration class:
public function setup()
{
// ...
if ($this instanceof sfApplicationConfiguration && !$this->isDebug())
{
require_once sfConfig::get('sf_lib_dir') . '/doctrine.compiled.php';
}
}
To make it all work we have to use the Doctrine_Core class and not Doctrine. The later will not be compiled.
Task works with the latest versions of symfony 1.3 and 1.4.