Page MenuHomePhabricator

Retrieval of Memcached values containing Message objects spend significant time in Title::newFromText
Closed, ResolvedPublic

Description

Follows from investigation for T242024: Investigate load.php backend latency and minify-calls regression (November 2019)

It seems that on a typical enwiki load.php request for modules=startup, there are 250 calls to Message::unserialize (all via MemcachedPeclBagOStuff::doGetMulti).

This spends a majority of its time in 237 calls to Title::newFromText which needs to perform title parsing, which is fairly expensive.

I imagine (not yet confirmed) there is a similar overhead on the storing side where it has to invoke TitleFormatter operations.

Proposal

Store a namespace/dbkey instead (possibly based on LinkTarget, or an array that mirrors it).

A possible follow-up could be to kick off the larger propagation of the classes Message -> MessageCache::parse -> Parser::parse which still only accept a Title object today which is wasteful because it pays for title parsing upfront regardless of how much it is or isn't needed, such as for ->plain().

It would be nice if the new REST API, and load.php etc. in methods like ResourceLoaderContext::msg() could then pass a LinkTarget internally for their dummy placeholders instead which would be significantly cheaper.

Related history

Event Timeline

Krinkle created this task.Mar 5 2020, 9:19 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 5 2020, 9:19 PM
Aklapper renamed this task from Retreival of Memcached values containing Message objects spend significant time in Title::newFromText to Retrieval of Memcached values containing Message objects spend significant time in Title::newFromText.Mar 6 2020, 9:28 AM

Change 577349 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] language: Avoid title parsing cost for serialised Message objects

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

Change 577349 merged by jenkins-bot:
[mediawiki/core@master] language: Avoid title parsing cost for serialised Message objects

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

Gilles moved this task from Inbox to Doing on the Performance-Team board.Mar 10 2020, 5:27 PM
Krinkle claimed this task.Mar 10 2020, 5:27 PM
Krinkle triaged this task as Medium priority.
Krinkle moved this task from Doing to Blocked or Needs-CR on the Performance-Team board.EditedMar 10 2020, 5:49 PM

Keeping open until I've verified it in prod.

Krinkle closed this task as Resolved.Mar 12 2020, 1:12 AM