Optimise container compiler passes for install

Created on 1 December 2020, about 4 years ago
Updated 22 July 2024, 4 months ago

Problem/Motivation

During install most of the time is spent building the container. See https://blackfire.io/profiles/0aae6482-d431-43e3-8bef-ee0916976585/graph...() which clearly shows the 14 module installs of a minimal install and their subsequent container rebuilds.

Our container by default registers a number of container passes to optimise the container. Considering we're going to throw the container away maybe the time spent making the optimisations is not worth it.

Proposed resolution

Remove InlineServiceDefinitionsPass, RemoveUnusedDefinitionsPass, AnalyzeServiceReferencesPass and ReplaceAliasByActualDefinitionPass during the installer do not do unnecessary work. This results in 1000s of less function calls and a quicker install. See the comparison for a standard install - https://blackfire.io/profiles/compare/612e435c-5c03-48b3-99a3-80c1846396...

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

9.3

Component
InstallΒ  β†’

Last updated 3 days ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡©πŸ‡ͺGermany donquixote

    Hello,
    it makes sense to remove compiler passes that are purely for optimization, and that don't change behavior.

    However, the RemoveUnusedDefinitionsPass is not designed purely for optimization.

    In a symfony project, the following use case is typical:
    - Scan a directory and register every class as a private service. This will include classes that absolutely cannot be used as services.
    - Process all the services with autowire, autoconfigure etc. This will also populate the error list for broken services.
    - Remove unused private services. This will usually get rid of the broken services that were added earlier.

    This means RemoveUnusedDefinitionsPass is essential if we have any mechanism that adds random classes as private services.
    If we don't have this mechanism, then we never need it: Not during the installer, but also not really later.

    I mention all this because I am currently experimenting with service discovery.

Production build 0.71.5 2024