Problem/Motivation
When importing existing configuration during site install, importing translated strings is very slow

Drupal\local\Gettest::fileToDatabase generates a call to Drupal\locale\PoDatabaseWriter::importString for each string which is then individually written to the database - in my case, for 6 languages, this caused an additional 51,000+ database writes on install and the installer takes around 10m to complete.
Proposed resolution
Support adding more than 1 translated string at a time to the database
Remaining tasks
tbd
API changes
tbd
Release notes snippet
tbd
Comments
Comment #2
justafishComment #5
heddnLink to #3037156: Modernize locale history functions.
Comment #6
heddnWhen running things using mysql backend, the xhprof seen above is what I see on 9.3. When running with a sqlite backend, I see the trace in #3037156-25: Modernize locale history functions.
The install time really took a hit in 9.3 vs 9.2. I saw install time go from ~18 minutes with 40+ languages in 9.2 grow to 2.5-3hrs in 9.3. Something really make it take a lot longer after the upgrade.
Comment #7
heddnAlso linking in #3125440: Impossible to skip interface translations download on Drupal install.
Comment #8
joao.ramos.costa commentedThanks @heddn .
I can report the same issue. An install time from config with 20+ languages in 9.2 took ~8 min and grow to 40 min in 9.3 .
Comment #9
heddnSee #2925203: LocaleConfigSubscriber can result in data loss during install, that probably exacerbated the problem. I think someone could remove that from the install by implementing
hook_install_tasks_alterand removing_install_config_locale_overridesfrom the list of install tasks.But importing strings shouldn't be so painfully slow. We should cache the info data better (without clearing it every time on a partial miss) and we should bulk insert the strings instead of one by one.
Comment #10
dxvargas commentedI'm adding this related issue that seems to have uncovered this problem.
When I undo the change (use $batch instead of $batch_definition), the installation is much faster, like before.
Seems like translation batches were being skipped until now. After the merge of the related issue, they started to be processed.
We should improve the translation import process for sure.
But this case also shows that translations may not be relevant when installing the site, since the related issue went unnoticed by many during so much time. Shouldn't we have a option to opt out?
Comment #11
dxvargas commentedThe patch #3 in this related issue helps, I have an improvement in performance when installing it.
Comment #13
dxvargas commentedIssue #3074765 is now merged, it would be nice to check the issue here again.
I believe it is the same problem and this issue may be closed.
Comment #14
heddnIn our case, this was the solution. I'd say this is duplicate. If that isn't the case for someone else, please re-open and list more specifics about the differences.