Page MenuHomePhabricator

LocalisationCache loads key "preload" twice on all page views
Closed, DeclinedPublic

Description

From the debug log in a Jenkins job:

Start request GET /index.php?title=…
…
[caches] cluster: APCUBagOStuff, WAN: mediawiki-main-default, stash: db-replicated, message: APCUBagOStuff, session: APCUBagOStuff
[localisation] LocalisationCache: using store LCStoreDB
…
[DBQuery] Wikimedia\Rdbms\DatabaseMysqlBase::serverIsReadOnly [0.001s]: SHOW GLOBAL VARIABLES LIKE 'read_only'
[DBQuery] Wikimedia\Rdbms\Database::beginIfImplied (LCStoreDB::get) [0s]: BEGIN

[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'deps'  LIMIT 1  
[DBQuery] LCStoreDB::get [0.001s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'list'  LIMIT 1  
[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'preload'  LIMIT 1  

[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'preload'  LIMIT 1  
[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'specialPageAliases'  LIMIT 1  
[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'namespaceGenderAliases'  LIMIT 1  
[DBQuery] LCStoreDB::get [0s]: SELECT  lc_value  FROM `l10n_cache`    WHERE lc_lang = 'en' AND lc_key = 'list'  LIMIT 1  
[DBQuery] MessageCache::loadFromDB(en)-big [0s]: SELECT  page_title,page_latest  FROM `page`    WHERE page_is_redirect = '0' AND page_namespace = '8' AND (page_title NOT LIKE '%/%' ESCAPE '`' ) AND (page_len > 10000)  
[DBQuery] MessageCache::loadFromDB(en)-small [0.001s]: SELECT  …

Note how it fetches preload twice, that shouldn't happen. Looking at the code in LocalisationCache::initLanguage, I believe it is happening as follows:

  • LocalisationCache::initLanguage
    • $this->isExpired
      • getItem('deps'),
      • getItem('list')
      • getItem('preload')
    • $this->getItem(…, 'preload')

Event Timeline

Krinkle triaged this task as Medium priority.Jul 30 2019, 2:49 PM
Krinkle moved this task from General to LocalisationCache on the MediaWiki-libs-BagOStuff board.
Krinkle moved this task from Limbo to Perf recommendation on the Performance-Team (Radar) board.

Is there anything that justifies the additional complexity that is likely required to avoid reading it twice?

A hacky workaround would be undesirable, but I think with some thought it could be reworked to naturally not need it twice.

But, I see now that this only applies when manualRecache = false which isn't the case in production. For high performance, this should always be set to true in which case this double load doesn't happen either. So not a concern I suppose.