Installing from existing config causes massive cache.config population and slow installs

Created on 20 November 2025, 2 months ago

Problem/Motivation

When installing a site from an existing configuration, the number of cached entries written to the cache.config bin becomes extremely large. This causes PHP to spend a significant amount of time iterating over these entries every time \Drupal\Core\Cache\MemoryBackend::invalidateTags() is called (for example, whenever configuration or an entity is saved). This dramatically slows down the installation process.

During installation, core alters cache_factory to use MemoryBackendFactory in \Drupal\Core\Installer\NormalInstallerServiceProvider::register(). However, disabling the config cache entirely results in much faster install times.

Without disabling it, MemoryBackend::invalidateTags() must iterate over tens of thousands of cached entries on every entity save or cache invalidation.
See:
- \Drupal\Core\Entity\EntityBase::postSave()
- \Drupal\Core\Cache\MemoryBackend::invalidateTags()

This problem is especially visible on multilingual sites. The config cache contains each configuration item once per language, because \Drupal\Core\Config\CachedStorage::getCacheKeys() includes the collection as part of the key prefix.
For example:
A site with 2000 configs in config/sync and 24 languages will produce roughly 2000 + (2000 × 24) = 50K cached entries in cache.config during installation.

Steps to reproduce

Either:
- Find a large site with lots of configs and languages that can be installed from existing config
- Or install drupal with minimal profile, add lots of languages (faster with php script)

Then compare install times with and without the provided fix.

Proposed resolution

Remaining tasks

TODO

User interface changes

TODO

Introduced terminology

TODO

API changes

TODO

Data model changes

TODO

Release notes snippet

TODO

📌 Task
Status

Active

Version

11.0 🔥

Component

install system

Created by

🇧🇪Belgium herved

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Fixed 12 days ago
Production build 0.71.5 2024