Bug #43540
closedTask #52304: Performance issues
TS is fetched from cache incorrectly sometimes
100%
Description
If $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']
or $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']
are set in the Install tool, cached TS will not be found in cache. This would result in TS parsing every time when there are USER_INT objects on the page. Generally it will slow down the page with USER_INT objects by at least 300% comparing to the non-cached version.
More information
When template parser processes the TS, it makes a hash to load a cached version of TS:
$this->runThroughTemplates($theRootLine); ... $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum)); $result = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($rowSumHash);
There TS can be fetched from the cache. If nothing is returned, the TS is parsed and stored into the cache:
$this->generateConfig(); ... $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum)); \TYPO3\CMS\Frontend\Page\PageRepository::storeHash($rowSumHash, serialize($cc['all']), 'TMPL_CONDITIONS_ALL');
Function generateConfig()
prepends values from the above-mentioned variables before processing the data. The earlier called function runThroughtTemplates()
does not do that. If the variables are empty, it does not make any difference and everything is cached. But if those variables are not empty (even if there is a single space), the $this->rowSum will be different in two quoted code extracts above. Thus TS will be stored with one hash value and the next request will try to retrieve it with another hash value. This means that cached TS will never be retrieved and will be always parsed.
We were able to decrease page generation from 2.88s to 0.8s by fixing the issue. 2 seconds make a huge difference in speed and load of the web server.