Problem/Motivation
I have a project with a lot of configurations (3 037, mostly because of multiple languages). The site installation from existing configuration (drush site:install --existing-config
) takes about 10 minutes. I did profile the installation and this is the TOP 10 slow calls:
Image may be NSFW.
Clik here to view.
As you can see, Drupal\Core\Config\FileStorage->getAllCollectionNamesHelper()
is the slowest operation during installation.
Also, take a look at php::SplFileInfo->isDir()
. It called 13'937'541 times, and almost all the calls (13'919'940) comes from Drupal\Core\Config\FileStorage->getAllCollectionNamesHelper()
, but php::SplFileInfo->isDir()
is slow by itself:
Image may be NSFW.
Clik here to view.
This is clearly because Drupal\Core\Config\FileStorage->getAllCollectionNamesHelper()
doesn't cache its result in any way. It's always calculated in runtime. It seems to me like a bottleneck.
Steps to reproduce
Install the website from existing configs and profile it. The more configs you have, the more problems you will see.
Proposed resolution
Provide at least a static caching for the results of this method.
Remaining tasks
- Provide a patch with a static caching and see how tests are going.
- Decide should it be cached and how.
- Implement it.