Issue #3492438: Prevent repeated route rebuilds during module installation

This patch reduces unnecessary route rebuilds during module installation by using a static flag that persists across container rebuilds.

During module installation, the container is rebuilt multiple times, creating new RouteProviderLazyBuilder instances with $rebuilt = FALSE. Previously, each new instance would trigger a route rebuild when getRouteProvider() was called, resulting in 34+ rebuilds during a typical installation (e.g., YMCA Website Services profile).

Changes:

  • RouteProviderLazyBuilder: Add static $globalRebuilt flag that persists across container rebuilds, ensuring only one rebuild per request.
  • ModuleInstaller: Skip route rebuilds and cache flushes during config sync operations (install/uninstall) - these will be done after import.
  • install.core.inc: Reset static state after install_finished() to allow subsequent rebuilds if needed and ensure clean state for tests.

Performance improvement: 88% reduction in route rebuilds (34→4), saving ~14 seconds during installation.

Closes #3492438

  Route Rebuild Comparison

  | Metric                         | Without Fix | With Fix  | Improvement |
  |--------------------------------|-------------|-----------|-------------|
  | RouteBuilder::rebuild calls    | 34          | 4         | -88%        |
  | LazyBuilder triggered rebuilds | 31 (15.20s) | 1 (0.22s) | -97%        |
  | Total rebuild time             | 17.01 sec   | 2.71 sec  | -84%        |
  | % of install time              | 8.7%        | 1.5%      | -7.2 points |

  Overall Impact

  | Metric     | Without Fix | With Fix   | Improvement       |
  |------------|-------------|------------|-------------------|
  | Total Time | 195.99 sec  | 183.23 sec | -12.76 sec (6.5%) |
  | Memory     | 325 MB      | 319 MB     | -6 MB             |

  Summary

  The fix reduced route rebuilds from 34 to 4 (one initial + install_finished + 2 from uninstall), saving 14.3 seconds in rebuild time alone.

Merge request reports

Loading
Loading