[TYPO3-dev] Speeding up INT objects in FE

Jigal van Hemert jigal at xs4all.nl
Sun Jul 11 11:50:11 CEST 2010


Hi,

It seems that (uncached) INT objects in a page form a major contribution 
to the time needed to serve a page. Even if the object itself doesn't do 
much unserializing it seems to take a considerable amount of time.

Ideas:

1. Reduce the size of the cObj [1]
The magic method __sleep() can return an array of names of class 
properties which need to be included in the serialized data. If 
tslib_cObj objects do not need all their properties survive the 
serialize/unserialize procedure this may speed up the process.

2. Make cObj serializable [2]
If the class implements the Serializable interface there are two extra 
methods available: serialize() and unserialize($data).
serialize() returns the serialized data which needs to be preserved.
unserialize() restores the property values
This is variation of 1. The interface is available in PHP >= 5.1.0

3. Use var_export() [3] [4]
var_export() produces a PHP parsable representation of the object. Since 
PHP >= 5.1.0 it can export classes too, but the class needs a method 
__set_state() [5] to restore the property values.
Pros:
+ seems to be faster than serialize
+ result is better readable than that of serialize
Cons:
- if __set_state() is not implemented in an object contained in the 
exported object it will result in a Fatal error: Call to undefined 
method <class>::__set_state
- doesn't support circular references

[1] 
http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep
[2] http://www.php.net/manual/en/class.serializable.php
[3] http://www.php.net/manual/en/function.var-export.php
[4] 
http://blog.perplexedlabs.com/2008/02/12/php-fast-large-megabyte-data-transfer-between-sessions/
[5] 
http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.set-state

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list