Page MenuHomePhabricator

VisualEditor is slow to load on Hebrew Wikipedia
Closed, ResolvedPublicBUG REPORT

Description

Latency metrics for getPageHTML on hewiki show a degradation from about 100ms at the beginning of March to about 800ms at the beginning of April: https://grafana.wikimedia.org/goto/14eNAfEVz?orgId=1 (note that the graph is log scale, and shows a one-day running average).

Note that hewiki is one of the wikis where we have been testing VisualEditor in "direct" mode: access to Parsoid is done by direct calls to PHP methods and makes use of ParserCache, instead of going through RESTbase.

Analysis:

Event Timeline

daniel updated the task description. (Show Details)

Change 910762 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] DNM: Add logging to investigate parser cache issue

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

Mentioned in SAL (#wikimedia-operations) [2023-04-21T11:56:12Z] <duesen> monky-patching Ib11a871ff on mwdebug2001 to investigate T335183

Mentioned in SAL (#wikimedia-operations) [2023-04-21T12:18:19Z] <duesen> reverted monky-patch, mwdebug2001 and deploy2002 are back to wmf/1.41.0-wmf.5 (T335183)

I made a DNM patch to log more info about what prevents ParserOutput from being cached: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/910762. I pulled this onto mwdebug2002 and used the MediawikiDebug plugin for Firefox to make a request with xhprof and detailed logging enabled. I then looked at the debug output on logstash: https://logstash.wikimedia.org/goto/10efd3e9b4f441b3bb93af7d9e473f43

The log shows that the reason that the ParserOutput is not getting cached is that the targetLanguage option is set to "he". The presence of "targetLanguage" indicates that variant conversaion was applied, but since "he" is identical to the original page language (and isn't a variant), this is not actually true.

The solution will be to not attempt redundant variant conversion. There is already a patch up for this: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/906652 [EDIT: this will not be sufficient]

Change 906652 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] HtmlOutputRendererHelper: skip redundant variant conversion

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

daniel renamed this task from VisualEditor is low to load on Hebrew Wikipedia to VisualEditor is slow to load on Hebrew Wikipedia.Apr 21 2023, 12:26 PM
daniel triaged this task as High priority.

Analysis:

  • VE's ApiParsoidTrait will determine the page language and passes it to the DirectParsoidClient, which ends up calling HtmlOutputRendererHelper::setPageLanguage().
  • HtmlOutputRendererHelper will call ParserOutput::setTargetLanguage if a language was set through setPageLanguage() earlier.
  • ParserOutput::setTargetLanguage causes caching to be disabled.

Idea:
HtmlOutputRendererHelper should not call ParserOutput::setTargetLanguage if the language set by setPageLanguage() is the same as the default page language. However, there currently is no good canonical way to determine the default page language.

Overall, it's unclear under which conditions which parts of the code need to have a language set explicitly. It seems like the original intent was to allow a language to be specified during page creation. I1bbf9c2180de2d91679edbc9d73adfe44075dde3 unfortunately lacks context (I only have myself to blame for that).

Change 912358 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] HtmlOutputRendererHelper: avoid splitting parser cache on page language

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

Change 912358 merged by jenkins-bot:

[mediawiki/core@master] HtmlOutputRendererHelper: avoid splitting parser cache on page language

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

Latency for getPageHtml is back down below 120ms, resolving.