Problem/Motivation

Currently importing of .po files for projects could take unacceptable about of time.

Proposed resolution

I have found that problem related to implementation of locale_translation_status_save();
This could be solved by this changes:

 function locale_translation_status_save($project, $langcode, $type, $data) {
   // Load the translation status or build it if not already available.
   module_load_include('translation.inc', 'locale');
-  $status = locale_translation_get_status();
+  $status = locale_translation_get_status([$project]);
   if (empty($status)) {
     $projects = locale_translation_get_projects([$project]);
     if (isset($projects[$project])) {

Remaining tasks

Don't see for now.

User interface changes

No changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chewie created an issue. See original summary.

Chewie’s picture

Chewie’s picture

Issue summary: View changes
Chewie’s picture

Chewie’s picture

Version: 8.7.x-dev » 8.8.x-dev
Issue tags: +Performance
Denes.Szabo’s picture

Status: Needs review » Needs work

What do you mean "unacceptable about of time"? How do you calculate the time? How much speed (time) you gained?
Why your solution solve the problem?

Chewie’s picture

Initially this issue was detected by executing drush command oe-multilingual:import-local-translations of opensource project https://github.com/openeuropa/oe_multilingual (version: 1.1.1).
I didn't check but probably performance issue could be also reproducible by standard drush command: locale:import.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Sutharsan’s picture

I think to remember, from when I wrote this code, that this call in on purpose. I think that there were situations when the list of available projects did not initialize, this may have been a way to overcome that. But that was 7 years ago... I may be wrong.

I think Denes.Szabo's questions are sensible and should be answered before we proceed with a solution.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

SpadXIII’s picture

Status: Needs work » Needs review

I ran across this issue as well. Importing the translations would take up to 35 minutes for a single site.
Some info about our site: it uses drupal 8, has about 100 modules enabled, and has 7 languages enabled. It is configured to only look for translations in local files and not download those (as they are downloaded locally). The translations files exist for only 2 of these languages (EN and NL).

Without this change, the method `locale_translation_status_save()` would take about 4.5-4.8 seconds to complete, per project, per language. So a total of about 32-35 seconds per project.
With this change, this was a little bit faster: per project, the first language took 45-50 ms and the languages after took less than 10ms. So a total of about 100-120 ms per project.

I did the quick benchmark by adding a few Timer::start and Timer::read in `locale_translation_check_projects_local()`. This method is called when doing a drush locale:check.
I'm setting this back to needs review, so others will have a look as well :)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

heddn’s picture

re #10, unacceptable is 45 minutes on one site to 2 hours on another during site install. If this brings that down to 5,10 15 minutes, that is a way more acceptable timeframe.

dxvargas’s picture

Status: Needs review » Reviewed & tested by the community

The proposed patch #3 makes a huge difference. Installation time came down from +20m to -10m.
I'll mark it as RTBC.
Because of https://www.drupal.org/project/drupal/issues/3150185, I wonder if this one's priority should be considered major.

quietone’s picture

Version: 9.4.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

This is testing a patch on Drupal 8.7 and Drupal 8 is End of Life. This needs a patch for 10.0.x.

dxvargas’s picture

heddn’s picture

Status: Needs work » Reviewed & tested by the community

I tested this on a 40+ language site with tons of translations in each of the languages and 86 contrib modules. WAY faster install times. And even running the drush command to pull down translations is a LOT faster.

RTBC++

Status: Reviewed & tested by the community » Needs work
Ankit.Gupta’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
756 bytes

Reroll the patch #19 with Drupal 10.0.x

dxvargas’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #22 is basically the same as in #19 which was RTBC.
It is good, I put the ticket back into RTBC.

It would be nice to have this merged, since it brings a good performance enhancement.

  • catch committed 03a3ac0 on 10.0.x
    Issue #3074765 by Chewie, dxvargas, Ankit.Gupta, heddn, Denes.Szabo,...
  • catch committed e2fcbd9 on 10.1.x
    Issue #3074765 by Chewie, dxvargas, Ankit.Gupta, heddn, Denes.Szabo,...
  • catch committed 9f02d0b on 9.4.x
    Issue #3074765 by Chewie, dxvargas, Ankit.Gupta, heddn, Denes.Szabo,...
  • catch committed 70794a8 on 9.5.x
    Issue #3074765 by Chewie, dxvargas, Ankit.Gupta, heddn, Denes.Szabo,...
catch’s picture

Version: 10.0.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x and cherry-picked back to 9.4.x, nice find and thanks for the various manual testing everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.