Page MenuHomePhabricator

When using Special:Translate, loading the documentation for a given message takes a noticable amount of time
Open, HighPublic2 Estimated Story PointsPRODUCTION ERROR

Description

Steps to replicate the issue

What happens?
The documentation for the message takes a noticeable amount of time to load.
Behind the scenes, it looks like my browser is querying https://www.mediawiki.org/w/api.php?action=translationaids&format=json&title=Translations:Extension:EmailAuth/16/nl&uselang=en. Visiting that URL directly, it seems like it's consistently taking ~4-5 seconds for the server to issue a response.

For some other translation units, the performance can be even worse - e.g., https://www.mediawiki.org/w/api.php?action=translationaids&format=json&title=Translations%3AExtension%3AEmailAuth%2F3%2Fnl&uselang=en consistently takes ~10 seconds to respond for me; and (judging from the API response) it seems like that's because Elasticsearch times out after that amount of time (stack trace taken from the ["helpers"]["ttmserver"]["error"] JSON key of the API response):

Elastica exception: Elastica\\Exception\\Connection\\HttpException: Operation timed out in /srv/mediawiki/php-1.45.0-wmf.9/vendor/ruflin/elastica/src/Transport/Http.php:186
Stack trace:
#0 /srv/mediawiki/php-1.45.0-wmf.9/vendor/ruflin/elastica/src/Request.php(183): Elastica\\Transport\\Http->exec(Object(Elastica\\Request), Array)
#1 /srv/mediawiki/php-1.45.0-wmf.9/vendor/ruflin/elastica/src/Client.php(545): Elastica\\Request->send()
#2 /srv/mediawiki/php-1.45.0-wmf.9/vendor/ruflin/elastica/src/Search.php(352): Elastica\\Client->request('ttmserver/_sear...', 'POST', Array, Array)
#3 /srv/mediawiki/php-1.45.0-wmf.9/vendor/ruflin/elastica/src/Index.php(546): Elastica\\Search->search(Object(Elastica\\Query), NULL, 'POST')
#4 /srv/mediawiki/php-1.45.0-wmf.9/extensions/Translate/src/TtmServer/ElasticSearchTtmServer.php(145): Elastica\\Index->search(Object(Elastica\\Query))
#5 /srv/mediawiki/php-1.45.0-wmf.9/extensions/Translate/src/TtmServer/ElasticSearchTtmServer.php(72): MediaWiki\\Extension\\Translate\\TtmServer\\ElasticSearchTtmServer->doQuery('en', 'nl', 'While this is l...')
#6 /srv/mediawiki/php-1.45.0-wmf.9/extensions/Translate/src/TranslatorInterface/Aid/TTMServerAid.php(69): MediaWiki\\Extension\\Translate\\TtmServer\\ElasticSearchTtmServer->query('en', 'nl', 'While this is l...')
#7 /srv/mediawiki/php-1.45.0-wmf.9/extensions/Translate/src/TranslatorInterface/Aid/TranslationAidsActionApi.php(112): MediaWiki\\Extension\\Translate\\TranslatorInterface\\Aid\\TTMServerAid->getData()
#8 /srv/mediawiki/php-1.45.0-wmf.9/includes/api/ApiMain.php(2016): MediaWiki\\Extension\\Translate\\TranslatorInterface\\Aid\\TranslationAidsActionApi->execute()
#9 /srv/mediawiki/php-1.45.0-wmf.9/includes/api/ApiMain.php(954): MediaWiki\\Api\\ApiMain->executeAction()
#10 /srv/mediawiki/php-1.45.0-wmf.9/includes/api/ApiMain.php(925): MediaWiki\\Api\\ApiMain->executeActionWithErrorHandling()
#11 /srv/mediawiki/php-1.45.0-wmf.9/includes/api/ApiEntryPoint.php(152): MediaWiki\\Api\\ApiMain->execute()
#12 /srv/mediawiki/php-1.45.0-wmf.9/includes/MediaWikiEntryPoint.php(198): MediaWiki\\Api\\ApiEntryPoint->execute()
#13 /srv/mediawiki/php-1.45.0-wmf.9/api.php(44): MediaWiki\\MediaWikiEntryPoint->run()
#14 /srv/mediawiki/w/api.php(3): require('/srv/mediawiki/...')
#15 {main}

What should have happened instead?
Translation units' documentation shouldn't take that long to load when using Special:Translate to translate a page.

Software version
1.45.0-wmf.9

Other information/Notes

  • One risk of the slow load times is that translators might not wish to wait for the documentation to load before translating a given message, which seems like it could unintentionally defeat the purpose of creating documentation for translation units in the first place.
  • I'm tagging Elasticsearch here as well, as it seems like the slow response times might be due in large part to the "ttmserver" response times (which, judging by https://www.mediawiki.org/wiki/Help:Extension:Translate/Translation_memories, is powered by Elasticsearch).
  • As an idea, if improving the ttmserver performance is tricky to do, maybe the message-documentation-fetching (and/or everything apart from querying ttmserver) could be split into its own API request, so that it's not affected (or hopefully affected less) by the slow speeds of querying ttmserver?

Event Timeline

Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald Transcript
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This uses some code called "Fuzzy Like This" which was removed from elasticsearch in 2015 due to performance issues (https://github.com/elastic/elasticsearch/pull/10391). To avoid the translate team needing to re-work this we took the old code and put it in our plugin, so the query still "works" but is painfully slow.

Plausibly to make this faster the query would have to be reworked to not use fuzzy-like-this.

We'll look into this for a day and try to come up with possible solutions.

pfischer set the point value for this task to 2.Aug 4 2025, 3:41 PM

Sorry if this interrupts any work, but I've realised that the Elasticsearch/TTMServer part of this task might be a potential duplicate of T101236: TTMServer performance and coverage issues.
The idea in this task's description to potentially split the message-doc-fetching into its own API request seems like it could be achieved separately, but I assume that wouldn't fall within the Search Platform team's scope… (and I'm guessing also might not be necessary if any solutions can be found to this on the Elasticsearch/Search Platform side of things).
Sorry about this!

Sorry if this interrupts any work, but I've realised that the Elasticsearch/TTMServer part of this task might be a potential duplicate of T101236: TTMServer performance and coverage issues.
The idea in this task's description to potentially split the message-doc-fetching into its own API request seems like it could be achieved separately, but I assume that wouldn't fall within the Search Platform team's scope… (and I'm guessing also might not be necessary if any solutions can be found to this on the Elasticsearch/Search Platform side of things).
Sorry about this!

No worries! Yes, performance issues in TTM is a known issue, if you believe that things got really worse recently we could possibly investigate if there are easy remediations otherwise we can mark this as a duplicate of T101236 indeed.

To be completely honest, this was probably the first time I've ever properly taken note of how long the translation docs/ttmserver responses take to load, so I'm afraid I can't really say whether things have got better/worse recently or not - apologies!


Re whether or not to mark this task as a duplicate -- I filed this task mainly from the POV of the translation documentation specifically taking so long to load, and - after looking into it - it seems like the final bullet-point of the task description might actually already be possible to do:

from the task description
  • As an idea, if improving the ttmserver performance is tricky to do, maybe the message-documentation-fetching (and/or everything apart from querying ttmserver) could be split into its own API request, so that it's not affected (or hopefully affected less) by the slow speeds of querying ttmserver?

By appending &prop=documentation to the API call (e.g., https://www.mediawiki.org/w/api.php?action=translationaids&format=json&title=Translations:Extension:EmailAuth/16/nl&uselang=en&prop=documentation), it seems like this might already be possible(!)
So I guess, if splitting the one action=translationaids API call into two could be a way of resolving this specific task on the 'message-documentation-being-slow-to-load' side of things, maybe this task is distinct from T101236 after all (and maybe we should untag Elasticsearch)? /genq

@A_smart_kitten thanks for the suggestion, this optimization would indeed be unrelated to Elasticsearch and thus going to untag it, I believe MediaWiki-extensions-Translate is the right tag for this request.

siebrand triaged this task as High priority.Sep 6 2026, 8:55 PM

Regardless of translation memory performance, I wonder if certain parts of the translator documentation can be displayed as soon as they are available instead of waiting for all translation helper content. I assume the challenges of this are repaints?

Front-end complexity and shifting content. Also, if you separate just ttmserver, you lose some of the benefit of the parallel-curl requests for MT/TM (though if I remember correctly, on WMF TM request is not even happening in parallel).