Page MenuHomePhabricator

Avoid DB lookups from Disambiguator when rendering interface messages
Closed, ResolvedPublic

Description

[…]
2% ~5ms : Disambiguator ext Hooks::onGetLinkColours, similar to the PageAssessments issue, but less severe because only 2 of the wikitext-parsed interface messages on this page contain links. It is adding overhead by querying the database separately for each linked page title to add the mw-disambig class. They are however uncached database queries that multiply by N for each parsed interface message on the page that contains a link. It was introduced in 2014 (T10339). During a normal page parse this is batched, but because each message is parsed separately, this is ineffective. I suggest we limit this to page content by turning it off for interface messages.

[…]

We can also observe these percentages via the aggregate MediaWiki Entrypoint Profiling: One component dashboard. The percentages are lower here since they take into account all action=view traffic, including special pages, diffs, and HTTP 304 responses:

ext_Disambiguator (6M)
Screenshot 2026-07-20 at 15.32.13.png (2,328×856 px, 147 KB)

As said, my suggestion would be to disable this feature in interface messages.

See also T313462 where we made a similar performance-driven change to disabled the LinkRenderer CSS classes from interface messages in the skin footer because, unlike links in the editable page content, these are not expected to be red links, redirects, disambig. And if they were to become that, these pages are stable enough and watched/visible enough that it doesn't warrant continously recomputing this on every pageview. If a prominent page like Wikipedia:Copyright becomes a red link, redirect, or disambig page, that's going to surface on its own quicky enough. There's also a reasonable chance that the styles wouldn't apply there anyway, due to them being outside .mw-parser-output.

Event Timeline

Krinkle assigned this task to MGoncalves-WMF.
Krinkle triaged this task as Medium priority.

Change #1319571 had a related patch set uploaded (by Milazg; author: Milazg):

[mediawiki/core@master] Parser: Avoid DB lookups from Disambiguator when rendering interface messages

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

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

[mediawiki/core@master] Parser: Improve GetLinkColours tests

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

Change #1319571 merged by jenkins-bot:

[mediawiki/core@master] Parser: Skip GetLinkColours hook when rendering interface messages

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

Change #1326333 merged by jenkins-bot:

[mediawiki/core@master] Parser: Improve GetLinkColours tests

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

After the change deployed on 2026-08-20, we saw a ~0.4 drop in time spent in ext_Disambiguator functions request in the wall-time graph below:

Screenshot 2026-08-28 at 16.30.40.png (2,672×898 px, 279 KB)

From ~1.21% to ~0.80% (average) representing ~30% relative drop.