Review main Merged

92536[TASK] Improve localization cache warmup performance

Benni Mack CR +2 V +2 Normal +84 −23 updated 01/29/26, 08:55

Commit message

This addresses several performance bottlenecks in the localization
cache warmer that caused O(n²) complexity during cache:warmup.

Bottleneck 1: Symfony Translator catalogue rebuilds
Symfony's addResource() clears the catalogue for that locale, and
getCatalogue() rebuilds it from ALL previously added resources.
The original code called getParsedData() for each file, which adds
resources then immediately retrieves the catalogue. With 1000 files,
this caused 1000 incremental catalogue rebuilds.

Fix: Separate warmup into two phases:
- Phase 1: Add all resources via new warmupTranslatorResource()
- Phase 2: Retrieve catalogues (built once per locale, not per file)

This reduces catalogue rebuilds from N (files) to M (locales).

Bottleneck 2: Redundant fallback locale processing
For each file, loadFilesIntoSymfonyTranslator() was called for all
fallback locales (e.g., de -> en -> default), repeatedly resolving
file paths and checking for overrides even when already processed.

Fix: Add early-exit cache check in loadFilesIntoSymfonyTranslator()
to skip fully processed file+locale combinations.

Bottleneck 3: Loop order causing locale switches
The original loop had packages in the outer loop, causing locale
switches between packages. Each switch triggers setFallbackLocales()
which clears ALL catalogues.

Fix: Collect all files first, then iterate with locales in outer
loop. This ensures fallback chain stays constant within each locale.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • Ayke Halder +1
  • Verified V +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • Ayke Halder +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1318

  1. Benni Mack uploaded patch set 1 01/27/26, 12:42

  2. core-ci voted on patch set 1 V +1 01/27/26, 12:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94426

  3. Ayke Halder commented on patch set 1 01/27/26, 14:12

    LocalizationFactory.php:127

    Let's try some refactoring here as this is duplicate code from `getParsedData()`

    LocalizationFactory.php:223

    AFAIK there might be different values for `$fileReference` ultimately resulting in the same real file to be included. Not sure if this gives a huge performance improvement here. Ideally the cache entry is set after resolving the actual file/unique reference to be loaded. E.g. `$actualSourcePath` is resolved in `addFileReferenceToTranslator()` - and a cache entry for the filename-locale-domain is already created there.
  4. Ayke Halder commented on patch set 1 01/27/26, 14:18

    LocalizationFactory.php:223 Reply

    Just checked it - and I don't see any improvements with `localization-factory-loaded` cache implemented here as there is a proper cache implemented in `addFileReferenceToTranslator()`. The filesystem is pretty fast on checking for (non-existing) files, as these calls to the filesystem are cached in memory - so no disk read operation needed on calling this multiple times for the same file.
  5. Ayke Halder uploaded patch set 2 V +1 01/27/26, 15:33

  6. core-ci voted on patch set 2 V -1 01/27/26, 15:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94433

  7. Ayke Halder uploaded patch set 3 V -1 01/27/26, 17:01

  8. Ayke Halder commented on patch set 3 CR +1 V +1 01/27/26, 17:06

    Voting on the code implemented by @benni@typo3.org

    LocalizationFactory.php:127 Reply

    Done

    LocalizationFactory.php:223 Reply

    Let's keep this additional cache as it is a clean solution to not load files twice.
  9. Ayke Halder uploaded patch set 4 CR +1 V +1 01/27/26, 17:10

  10. core-ci voted on patch set 3 V +1 01/27/26, 17:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94443

  11. core-ci voted on patch set 4 V +1 01/27/26, 17:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94444

  12. Benni Mack updated the commit message in patch set 5 V +1 01/27/26, 19:27

  13. Benni Mack marked it ready for review 01/27/26, 19:27

  14. core-ci voted on patch set 5 V +1 01/27/26, 19:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94446

  15. Ayke Halder voted on patch set 5 CR +1 V +1 01/28/26, 08:24

  16. Garvin Hicking voted on patch set 5 CR +1 V +1 01/28/26, 12:51

  17. Benni Mack voted on patch set 5 CR +2 V +2 01/29/26, 08:55

  18. Benni Mack merged patch set 6 01/29/26, 08:55