- πΊπΈUnited States smustgrave
π Remove unnecessary router rebuild from Standard installation Closed: duplicate closed as a duplicate
Drupal rebuilds the router on each module installation. This is useful when adding modules once Drupal has been installed.
However, it is causing a lot of CPU cycles when Drupal is installing and the routes may be rebuilt over and over. Here's a screenshot from a Blackfire profile shaal created while we were debugging the Umami demo's installation time. The router is rebuilt 55 times before Drupal has finished being installed.
Here is the current code:
if (!\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
// Rebuild routes after installing module. This is done here on top of
// \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
// fastCGI which executes ::destruct() after the module installation
// page was sent already.
\Drupal::service('router.builder')->rebuild();
}
Adding a check to drupal_installation_attempted ()
greatly improves the installation time. Here is the comparison when we check if Drupal is installed first
if (!drupal_installation_attempted() && !\Drupal::service('router.route_provider.lazy_builder')->hasRebuilt()) {
// Rebuild routes after installing module. This is done here on top of
// \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on
// fastCGI which executes ::destruct() after the module installation
// page was sent already.
\Drupal::service('router.builder')->rebuild();
}
Fixed
9.1
It affects performance. It is often combined with the Needs profiling tag.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
π Remove unnecessary router rebuild from Standard installation Closed: duplicate closed as a duplicate