Page MenuHomePhabricator

Vector2022 Do not call SkinMustache::getTemplateData twice
Closed, ResolvedPublic

Description

SkinMustache::getTemplateData() is called twice causing a performance impact. When tested on Special:UserLogin or Special:BlankPage. The profiler output (for a single call) stated that this method takes over 25% of the execution time (217 ms) when the profiler was enabled. The method itself is pretty complex and builds a big array that is passed to Mustache, calling it twice adds unnecessary performance downgrade.

The first time is called in:

> SkinMustache::getTemplateData (/srv/mediawiki/php-1.42.0-wmf.5/includes/skins/SkinMustache.php)
> MediaWiki\Skins\Vector\SkinVector22::getTemplateData (/srv/mediawiki/php-1.42.0-wmf.5/skins/Vector/includes/SkinVector22.php)
> SkinMustache::generateHTML (/srv/mediawiki/php-1.42.0-wmf.5/includes/skins/SkinMustache.php)
> SkinTemplate::outputPage (/srv/mediawiki/php-1.42.0-wmf.5/includes/skins/SkinTemplate.php)
> MediaWiki\Output\OutputPage::output (/srv/mediawiki/php-1.42.0-wmf.5/includes/Output/OutputPage.php)
> MediaWiki::main (/srv/mediawiki/php-1.42.0-wmf.5/includes/MediaWiki.php)
> MediaWiki::run (/srv/mediawiki/php-1.42.0-wmf.5/includes/MediaWiki.php)
> wfIndexMain (/srv/mediawiki/php-1.42.0-wmf.5/index.php)
> /srv/mediawiki/php-1.42.0-wmf.5/index.php (/srv/mediawiki/php-1.42.0-wmf.5/index.php)
> /srv/mediawiki/w/index.php (/srv/mediawiki/w/index.php)

And then the second call comes from SkinVector22:isTocAvailable:

> MediaWiki\Skins\Vector\SkinVector22::isTocAvailable (/srv/mediawiki/php-1.42.0-wmf.5/skins/Vector/includes/SkinVector22.php)
> MediaWiki\Skins\Vector\SkinVector22::getTemplateData (/srv/mediawiki/php-1.42.0-wmf.5/skins/Vector/includes/SkinVector22.php)
> SkinMustache::generateHTML (/srv/mediawiki/php-1.42.0-wmf.5/includes/skins/SkinMustache.php)
> SkinTemplate::outputPage (/srv/mediawiki/php-1.42.0-wmf.5/includes/skins/SkinTemplate.php)
> MediaWiki\Output\OutputPage::output (/srv/mediawiki/php-1.42.0-wmf.5/includes/Output/OutputPage.php)
> MediaWiki::main (/srv/mediawiki/php-1.42.0-wmf.5/includes/MediaWiki.php)
> MediaWiki::run (/srv/mediawiki/php-1.42.0-wmf.5/includes/MediaWiki.php)
> wfIndexMain (/srv/mediawiki/php-1.42.0-wmf.5/index.php)
> /srv/mediawiki/php-1.42.0-wmf.5/index.php (/srv/mediawiki/php-1.42.0-wmf.5/index.php)
> /srv/mediawiki/w/index.php (/srv/mediawiki/w/index.php)

The first call to getTemplateData takes around 150ms, then the second call is a bit faster ~50ms due to caching -> but it happens within the same function, therefore there is no need to use call parent::getTemplateData once again. Thanks to this improvement we can shave off up to ~6% per execution call for all requests to MediaWiki when the new Vector Skin is selected.

Event Timeline

Change 976705 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/skins/Vector@master] Skin shouldn't call SkinMustache::getTemplateData twice

https://gerrit.wikimedia.org/r/976705

pmiazga updated the task description. (Show Details)

Change 976705 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Skin shouldn't call SkinMustache::getTemplateData twice

https://gerrit.wikimedia.org/r/976705