Problem/Motivation
The new version of config_split relies heavily on the config dependency manager to calculate the configuration that should be included in a specific split. Unfortunately, this process doesn't scale well for sites with a large number of configuration entities that need to be split.
It appears there are some optimizations we can make within \Drupal\Core\Config\Entity\ConfigDependencyManager and \Drupal\Core\Config\ConfigManager to alleviate this issue.
The calls to array_multisort within ConfigDependencyManager::getDependentEntities account for a large majority of this time (~65%).
$sorts = $this->prepareMultisort($graph, ['weight', 'name']);
array_multisort($sorts['weight'], SORT_DESC, SORT_NUMERIC, $sorts['name'], SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE, $graph);
Checking a couple of references/call stacks to this function it doesn't look like the sorting is actually needed. This sorting code is also duplicated in ConfigDependencyManager::sortAll which is called by the config system elsewhere.
Additionally, within ConfigManager::findConfigEntityDependencies we could benefit from some type of caching. In my stack trace I saw it was executed about 150 times, but it called ConfigDependencyManager::getDependentEntities 130k times. I added static caching to this section of code and saw a roughly 20% improvement in performance.
Steps to reproduce
- Create site with approximately 50 paragraph types and 1200 config entities.
- Utilizing the config_split module and stackable split system, create a split with 10 of the paragraph entities.
- Observe config export time.
- Current: 5 minutes
- Without sorting: 45 seconds
- Static caching in findConfigEntityDependencies: 4 minutes
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet