Use a transaction PoDatabaseWriter to improve performance

Created on 23 April 2025, 1 day ago

Problem/Motivation

When creating or updating translations we do a lot of queries. Ideally we'd do less queries and bulk insert and update. But in lieu of re-writing all of this we could be inspired by πŸ› Configuration management performance regression - slow config:import Needs work and use transactions to speed up the process.

Steps to reproduce

Import translations to your site.

Proposed resolution

Open a transaction in \Drupal\locale\PoDatabaseWriter::writeItems()

Remaining tasks

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

N/a

πŸ“Œ Task
Status

Active

Version

11.1 πŸ”₯

Component

locale.module

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @alexpott
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Profiling results running time vendor/bin/drush si -y -v standard --account-mail=alex@example.com --account-name=admin --account-pass=PASSWORD --db-url=mysql://USER:PASSWORD@localhost/DB_NAME --locale=de

    With MR

    ________________________________________________________
    Executed in    7.29 secs    fish           external
       usr time    3.14 secs    0.21 millis    3.14 secs
       sys time    0.94 secs    3.19 millis    0.94 secs
    

    Without MR

    ________________________________________________________
    Executed in    9.45 secs    fish           external
       usr time    3.32 secs    0.25 millis    3.32 secs
       sys time    0.93 secs    2.56 millis    0.93 secs
    

    The results are pretty consistent and will benefit sites with more translation files to import.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    alexpott β†’ changed the visibility of the branch 3520750-use-a-transaction to hidden.

Production build 0.71.5 2024