Page MenuHomePhabricator

Page view triggers ResourceLoaderWikiModule db queries for enabled gadgets (from OutputPage)
Closed, ResolvedPublic

Description

In the debugging information I see a possibly unnecessary SQL query for each enabled gadget:

[DBQuery] (my wiki) SELECT /* ResourceLoaderWikiModule::getTitleInfo  */  page_namespace,page_title,page_touched,page_len,page_latest  FROM `page`    WHERE (page_namespace = '8' AND page_title IN ('Gadget-picPopup.css','Gadget-picPopup.js') )

Shoud this data not be cached somewhere?

MediaWiki configuration:

MediaWiki1.31.3 (d6ba909) 13:12, 24 июля 2019
PHP7.3.7-2+ubuntu19.04.1+deb.sury.org+1 (fpm-fcgi)
MariaDB10.3.17-MariaDB-1:10.3.17+maria~disco-log
ICU64.1
LilyPond2.18.2
LuaSandbox3.0.3
Lua5.1.5

Caching configuration:

$wgInvalidateCacheOnLocalSettingsChange = true;

$wgMainCacheType	= CACHE_ACCEL;
$wgEnableSidebarCache = true;
$wgCachePages = true;
$wgUseKeyHeader = true;

// Parser cache:
$wgRevisionCacheExpiry = 3*24*3600;
$wgParserCacheExpireTime = 60*60*24*7;

$wgMessageCacheType = $wgMainCacheType; //CACHE_ACCEL;
$wgUseLocalMessageCache = true;
$wgMaxMsgCacheEntrySize = 131072;
$wgShowExceptionDetails = true;
$wgCacheDirectory  = '/var/cache/mediawiki/' . $wgWiki;

$wgLocalisationCacheConf = [
	'class'			=> LocalisationCache::class,
	'store'			=> 'array',	// Use opcache.
	'storeClass'		=> false,	//
	'storeDirectory'	=> false,	// == $wgCacheDirectory
	'manualRecache'		=> true,	// -- no update on web requests. Use rebuildLocalisationCache.php.
];

$wgMsgCacheExpiry = 2 * 24 * 60 * 60;	// -- two days.

// See https://phabricator.wikimedia.org/T215726:
$wgWANObjectCaches [$wgMainCacheType] = [
    'class'     => WANObjectCache::class,
    'cacheId'   => $wgMainCacheType,
    'channels'  => []
];
$wgMainWANCache = $wgMainCacheType;

// Since MW 1.27, until something faster but as persistent is found:
$wgSessionCacheType = CACHE_DB;
$wgObjectCacheSessionExpiry = 3600;

ResourceLoader configuration:

$wgResourceLoaderMaxQueryLength = 4096;
// ResourceLoader caching:
$wgResourceLoaderMaxage = [
	'versioned' => [
		// Squid/Varnish but also any other public proxy cache between the client and MediaWiki
		'server' => 30 * 24 * 60 * 60, // 30 days
		// On the client side (e.g. in the browser cache).
		'client' => 30 * 24 * 60 * 60, // 30 days
	],
	'unversioned' => [
		'server' => 7 * 24 * 60 * 60, // 7 days
		'client' => 7 * 24 * 60 * 60, // 7 days
	]
];	// -- $wgResourceLoaderMaxage

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald Transcript

Change 529586 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] [ResourceLoader] Preload title info for js-only wiki modules

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

Is the query from page views (OutputPage), from the startup module (load.php), or from the gadget module response (load.php)?

If from page views, then it might not be an issue of caching but rather a bug that the query should not be made at all.

Is the query from page views (OutputPage), from the startup module (load.php), or from the gadget module response (load.php)?

Page views.

Change 530119 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Avoid isKnownEmpty call for regular (non-embed) modules

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

Krinkle renamed this task from Strange database queries for each enabled gadget to Page view triggers ResourceLoaderWikiModule db queries for enabled gadgets (from OutputPage).Aug 14 2019, 2:48 PM
Krinkle claimed this task.
Krinkle edited projects, added Performance-Team; removed Performance-Team (Radar).
Krinkle moved this task from Inbox to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Krinkle triaged this task as Medium priority.Aug 16 2019, 11:32 AM

Change 530119 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Avoid isKnownEmpty call for regular (non-embed) modules

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

Krinkle closed this task as Resolved.EditedAug 23 2019, 2:13 PM
Krinkle removed a project: Patch-For-Review.

@alex-mashin Could you confirm that this issue is resolved?

Change 529586 abandoned by Umherirrender:
[ResourceLoader] Preload title info for non styles wiki modules

Reason:
Superseeded by I4e6af2c833c92e1277713bdd0c68953d49c4dd9d

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

Looks good now

Will it be backported to LTS (1.31)?

@alex-mashin No, it's not a straight-forward bug fix. Would rather not risk the LTS with the refactor.