Page MenuHomePhabricator

Phase out SqlModuleDependencyStore
Closed, ResolvedPublic

Description

Background

Context: https://www.mediawiki.org/wiki/ResourceLoader/Architecture

Each module has a version hash. The startup module ships a registry of all module names and their hashes to the browser client. The server builds this registry in a single response (for the "startup" module). Given ~1000 modules, this leaves relatively little time for each module. As such, we employ broadly two mechanisms today to speed this up (compared to the naive approach of building all 1000 modules serially and then hashing their output):

  1. When responding with the startup registry, instead of fully building each module into a temporary variable and hashing its content, we instead take only the list of CSS and JS input file paths, hash the MD4 hashes of each file. The build step is designed to be deterministic. A software-defined version constant is hashed in to account for changes (e.g. change bundle format, update minifier, update Less compiler, etc.).
  1. To account for module output variance by indirect means, we wait for the first request for the actual module, take note of the files read, and the next time the startup registry is build, the version hash will take those into account. Thus after a deployment, some modules take one extra 5-minute cache window before reaching their final cache key. The important thing is that caches are always invalidated within 5 minutes. Invalidating one extra time before settling on a cache key is fairly harmless.

Examples of indirect file references:

  • A CSS stylesheet referencing a versioned SVG image. When the SVG file changes, the URL will change from background: url(foo.svg?11111) to background: url(foo.svg?22222). This means the stylesheet output has changed without the CSS file changing.
  • A Less stylesheet, when compiled to CSS, is generaly quite short with most of its code being imported from other .less files, whcih are then eventually flattened to a single large CSS file.

Status quo

When this feature first launched, we wrote this metadata into the core MediaWIki tables (the module_deps table). This was problematic at WMF scale for several reasons, including violating the best practice of not performing writes to the core DB cluster on GET requests, and being incompatible with Multi-DC. Details at T113916: Switch ResourceLoader file dependency tracking to MultiDC-friendly backend.

Short story: We introduced the MainStash service based on BagOStuff, and created a new DependencyStore implementation that uses this instead.

This is significantly faster for small wikis using sqlite as well, as it allows writes to go to a separate non-conflicing db file rather than the main one which is likely locked.

To do

  • Turn on wgResourceLoaderUseObjectCacheForDeps in MediaWiki 1.43 by default. (It is already turned on for Wikipedia at WMF.)
  • Remove the wgResourceLoaderUseObjectCacheForDeps setting in MediaWiki 1.44.
  • Remove the SqlModuleDependencyStore class.
  • Simplify DependencyStore by consolidating it with the KeyValueDependencyStore class.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Turn on wgResourceLoaderUseObjectCacheForDeps in MediaWiki 1.41 by default. (It is already turned on for Wikipedia at WMF.)

The branch cut is rather soon. Wanna make it a blocker for the release?

This is scheduled for FY2024-25 Q1 (Jul-Sep).

Change #1062771 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] ResourceLoader: Turn on ResourceLoaderUseObjectCacheForDeps by default

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

Change #1062771 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Turn on ResourceLoaderUseObjectCacheForDeps by default

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

Krinkle updated the task description. (Show Details)

Change #1064370 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] [ResourceLoader] Remove ResourceLoaderUseObjectCacheForDeps

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

Change #1064371 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] [ResourceLoader] Remove SqlModuleDependencyStore

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

Change #1069239 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] Test Indirect styles dependencies

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

Change #1070571 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] Resourceloader: Enable methods that stores and retrieves dependency during test

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

Change #1070571 merged by jenkins-bot:

[mediawiki/core@master] Resourceloader: Enable methods that stores and retrieves dependency during test

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

Change #1069239 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Test DependencyStore with indirect styles dependencies

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

Change #1071838 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[operations/mediawiki-config@master] Remove ResourceLoaderUseObjectCacheForDeps

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

Change #1071855 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/core@master] ResourceLoader: Empty KeyValueDependencyStore class before removal

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

Change #1071910 had a related patch set uploaded (by Hokwelum; author: Hokwelum):

[mediawiki/skins/Vector@master] ResourceLoader currently use KeyValueDependencyStore as the default Dependency store

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

Change #1071855 abandoned by Hokwelum:

[mediawiki/core@master] ResourceLoader: Empty KeyValueDependencyStore class before removal

Reason:

no longer used

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

Change #1071910 merged by jenkins-bot:

[mediawiki/skins/Vector@master] phpunit: Remove use of internal KeyValueDependencyStore class

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

Change #1071838 merged by jenkins-bot:

[operations/mediawiki-config@master] Remove ResourceLoaderUseObjectCacheForDeps

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

Mentioned in SAL (#wikimedia-operations) [2024-09-11T13:27:41Z] <dreamyjazz@deploy1003> Started scap sync-world: Backport for [[gerrit:1071838|Remove ResourceLoaderUseObjectCacheForDeps (T343492)]], [[gerrit:1072159|Generate special page name in English for central URLs (T374277)]], [[gerrit:1072176|IPInfoLogFormatter: Avoid unnecessary User object creation (T374526)]], [[gerrit:1071902|Add arbcom group to zhwiki (T374455)]], [[gerrit:1072177|Remove redundant oathauth-enable flag (

Mentioned in SAL (#wikimedia-operations) [2024-09-11T13:29:49Z] <dreamyjazz@deploy1003> jdrewniak, hokwelum, dreamyjazz, hamishz: Backport for [[gerrit:1071838|Remove ResourceLoaderUseObjectCacheForDeps (T343492)]], [[gerrit:1072159|Generate special page name in English for central URLs (T374277)]], [[gerrit:1072176|IPInfoLogFormatter: Avoid unnecessary User object creation (T374526)]], [[gerrit:1071902|Add arbcom group to zhwiki (T374455)]], [[gerrit:1072177|Remove redundant oatha

Mentioned in SAL (#wikimedia-operations) [2024-09-11T13:40:51Z] <dreamyjazz@deploy1003> Finished scap sync-world: Backport for [[gerrit:1071838|Remove ResourceLoaderUseObjectCacheForDeps (T343492)]], [[gerrit:1072159|Generate special page name in English for central URLs (T374277)]], [[gerrit:1072176|IPInfoLogFormatter: Avoid unnecessary User object creation (T374526)]], [[gerrit:1071902|Add arbcom group to zhwiki (T374455)]], [[gerrit:1072177|Remove redundant oathauth-enable flag

Change #1064639 had a related patch set uploaded (by Krinkle; author: Hokwelum):

[mediawiki/core@master] ResourceLoader: Simplify DependencyStore

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

Change #1064370 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Remove ResourceLoaderUseObjectCacheForDeps

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

Change #1064371 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Remove SqlModuleDependencyStore

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

Change #1064639 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Simplify DependencyStore

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

Hokwelum updated the task description. (Show Details)