Page MenuHomePhabricator

Reduce ChronologyProtector init cost for load.php
Closed, ResolvedPublic


A significant amount of the time in load.php is spent in MediaWiki WebStart.php, via wmf-config/CommonSettings. The biggest one within that seems to be Wikibase providing some values for an Echo hook. About 30x longer compared to Thanks, Flow and EducationProgram for the same Echo hook.

Screen Shot 2017-03-16 at 11.16.21.png (1×1 px, 172 KB)
Screen Shot 2017-03-16 at 11.18.12.png (1×2 px, 380 KB)

/includes/WebStart.php > EchoHooks::initEchoExtension > Wikibase\Client\Hooks\EchoNotificationsHandlers::onBeforeCreateEchoEvent (git-src)

public static function onBeforeCreateEchoEvent( .. ) {
	$self = self::newFromGlobalState();
	$self->doBeforeCreateEchoEvent( $notifications, $notificationCategories, $icons );

The actual call to doBeforeCreateEchoEvent() is runs too quickly to show up. It's mostly setting up the global instance. It seems some of the constructors involved do a lot of (presumably unnecessary) work in the constructor.

  • Wikibase\Client\WikibaseClient::getDefaultInstance
    • MediaWiki\MediaWikiServices::getSiteLookup
      • MediaWiki\MediaWikiServices::getSiteStore
        • MediaWiki\MediaWikiServices::getDBLoadBalancer
          • Wikimedia\Rdbms\LBFactoryMulti::getMainLB
            • Wikimedia\Rdbms\ChronologyProtector::initLB
              • Wikimedia\Rdbms\ChronologyProtector::initPositions

Event Timeline

Change 344573 had a related patch set uploaded (by Aaron Schulz):
[mediawiki/core@master] [WIP] Defer calling ChronologyProtector::initLB() until connecting

Krinkle triaged this task as Medium priority.Mar 25 2017, 2:32 AM
Krinkle moved this task from Inbox to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Krinkle moved this task from Accepted Enhancement to Assigned on the MediaWiki-ResourceLoader board.

Change 344573 merged by jenkins-bot:
[mediawiki/core@master] Defer calling ChronologyProtector::initLB() until connecting